Build error: (NSObjCRuntime.h & NSObject)
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:371:1: Expected unqualified-id
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:373:19: Unknown type name 'NSString'
...
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/objc/NSObject.h:11:1: Expected unqualified-id
...
[Solution]
rename extension name from .cpp into .mm
2014年7月29日 星期二
[Xcode] Fixed: _CMAudioFormatDescriptionGetStreamBasicDescription", referenced from: -[captureNSObject init] in captureNSObject.o
I have a project to build some code, and then it has error in the follow:
Undefined symbols for architecture x86_64:
"_CMAudioFormatDescriptionGetStreamBasicDescription", referenced from:
-[captureNSObject init] in captureNSObject.o
"_CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer", referenced from:
-[captureNSObject captureOutput:didOutputSampleBuffer:fromConnection:] in captureNSObject.o
"_CMSampleBufferGetNumSamples", referenced from:
-[captureNSObject captureOutput:didOutputSampleBuffer:fromConnection:] in captureNSObject.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[Solution]
Add CoreMedia.framework into "Linked Frameworks and Libraries".
2014年7月24日 星期四
[Xcode] Enable/disable a button
@property (retain, nonatomic) IBOutlet UIButton *btnButton;
enable/disable like this in .m file:
btnButton.enabled = NO; // disable button
btnButton.enabled = YES; // enable button
2014年7月20日 星期日
[Xcode] How to convert int to NSString
int nNum = 100;
NSString* str = [[NSString alloc]initWithFormat:@"%d", nNum];
2014年7月16日 星期三
[Xcode] How to quit the application when the window closes
If you want an application to quit (terminate) when the window is closed, you can do this:
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication
*)theApplication
{
return YES;
}
2014年7月14日 星期一
[Xcode] How to convert between NSTextField and NSString
// NSString --> NSTextField
NSTextField * txtField = [[NSTextField alloc] init];
NSString *str = @“1234”;
txtField.stringValue = str;
// NSTextField --> NSString
NSString *str1 = txtField.stringValue;
[Xcode] How to convert byte array to NSString
Byte* btData = new Byte[12];
memset(btData, 0, sizeof(Byte) * 12);
...
NSData *data = [NSData dataWithBytes:btData length:sizeof(btData)];
NSString *string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
2014年7月2日 星期三
[Xcode] Hotkey
command + X
- cut
command + C
command + V
- paste
command + A
- select all
command + /
- add/remove comment
command + \
- add/remove breakpoint
command + R
- run
command + B
- build
command + F
- find
shift + command + F
- find in project
command + option + F
- find and replace
shift + command + option + F
- find and replace in project
- cut
command + C
- copy
command + V
- paste
command + A
- select all
- add/remove comment
command + \
- run
- build
- find
- find in project
- find and replace
- find and replace in project
2014年6月11日 星期三
[Mac OS] How To Capture a Screen Shot with Mac OS X
1. Command+Shift+3
To capture the entire desktop, and then will be automatically saved as a PNG file on your desktop.
2. Command+Control+Shift+3
To copy the entire desktop, and then will be placed on your clipboard for you to paste into another program.
3. Command+Shift+4
To capture a portion of the desktop. A cross-hair cursor will appear and you can click and drag to select the area you wish to capture. When you release the mouse button, the screen shot will be automatically saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)
4. Command+Shift+4, then press the Spacebar
To capture a specific application window. The cursor will change to a camera, and you can move it around the screen. As you move the cursor over an application window, the window will be highlighted. The entire window does not need to be visible for you to capture it. When you have the cursor over a window you want to capture, just click the mouse button and the screen shot will be saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)
To capture the entire desktop, and then will be automatically saved as a PNG file on your desktop.
2. Command+Control+Shift+3
To copy the entire desktop, and then will be placed on your clipboard for you to paste into another program.
3. Command+Shift+4
To capture a portion of the desktop. A cross-hair cursor will appear and you can click and drag to select the area you wish to capture. When you release the mouse button, the screen shot will be automatically saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)
4. Command+Shift+4, then press the Spacebar
To capture a specific application window. The cursor will change to a camera, and you can move it around the screen. As you move the cursor over an application window, the window will be highlighted. The entire window does not need to be visible for you to capture it. When you have the cursor over a window you want to capture, just click the mouse button and the screen shot will be saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)
2014年4月6日 星期日
[Windows] How to lock your computer using command line
Step 1:
Open a DOS promot for launching a special command line. One simple way you can do it would be by clicking Start/Run, typing cmd.
Step 2:
Enter the command line for locking your station:
rundll32.exe user32.dll, LockWorkStation
Open a DOS promot for launching a special command line. One simple way you can do it would be by clicking Start/Run, typing cmd.
Step 2:
Enter the command line for locking your station:
rundll32.exe user32.dll, LockWorkStation
2014年3月3日 星期一
[Win32] How to get the app owner version?
Example:
CString strResult;
TCHAR szModPath[MAX_PATH];
ZeroMemory(szModPath, sizeof(TCHAR) * MAX_PATH);
GetModuleFileName(NULL, szModPath, sizeof(szModPath));
DWORD dwHandle;
DWORD dwSize = GetFileVersionInfoSize(szModPath, &dwHandle);
if (dwSize > 0)
{
BYTE* pbBuf = static_cast<BYTE*>(alloca(dwSize));
if (GetFileVersionInfo(szModPath, dwHandle, dwSize, pbBuf))
{
UINT uiSize;
BYTE* lpb;
if (VerQueryValue(pbBuf, L"\\VarFileInfo\\Translation", (void**)&lpb, &uiSize))
{
WORD* lpw = (WORD*)lpb;
CString strQuery;
strQuery.Format(L"\\StringFileInfo\\%04x%04x\\ProductVersion", lpw[0], lpw[1]);
if (VerQueryValue(pbBuf, const_cast<LPTSTR>((LPCTSTR)strQuery), (void**)&lpb, &uiSize ) && uiSize > 0)
{
strResult = (LPCTSTR)lpb;
}
}
}
}
CString strResult;
TCHAR szModPath[MAX_PATH];
ZeroMemory(szModPath, sizeof(TCHAR) * MAX_PATH);
GetModuleFileName(NULL, szModPath, sizeof(szModPath));
DWORD dwHandle;
DWORD dwSize = GetFileVersionInfoSize(szModPath, &dwHandle);
if (dwSize > 0)
{
BYTE* pbBuf = static_cast<BYTE*>(alloca(dwSize));
if (GetFileVersionInfo(szModPath, dwHandle, dwSize, pbBuf))
{
UINT uiSize;
BYTE* lpb;
if (VerQueryValue(pbBuf, L"\\VarFileInfo\\Translation", (void**)&lpb, &uiSize))
{
WORD* lpw = (WORD*)lpb;
CString strQuery;
strQuery.Format(L"\\StringFileInfo\\%04x%04x\\ProductVersion", lpw[0], lpw[1]);
if (VerQueryValue(pbBuf, const_cast<LPTSTR>((LPCTSTR)strQuery), (void**)&lpb, &uiSize ) && uiSize > 0)
{
strResult = (LPCTSTR)lpb;
}
}
}
}
[Win32] How to get the OS Version?
DWORD WINAPI GetVersion(void);
Examples:
#include <windows.h>
#include <stdio.h>
void main()
{
DWORD dwVersion = 0;
DWORD dwMajorVersion = 0;
DWORD dwMinorVersion = 0;
DWORD dwBuild = 0;
dwVersion = GetVersion();
// Get the Windows version.
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
// Get the build number.
if (dwVersion < 0x80000000)
dwBuild = (DWORD)(HIWORD(dwVersion));
printf("Version is %d.%d (%d)\n",
dwMajorVersion,
dwMinorVersion,
dwBuild);
}
2014年1月7日 星期二
[Java, Windows 8] How to transform Java List to Store apps C++/CX?
Java codes:
private static List<String> vv = new ArrayList<String>();
vv.add("area");
vv.add("base");
vv.add("basefont");
vv.add("br");
vv.add("col");
vv.add("frame");
vv.add("hr");
vv.add("img");
vv.add("input");
vv.add("isindex");
vv.add("link");
vv.add("meta");
vv.add("param");
String ss = "hr";
if (vv.contains(ss))
{
/* vv contains ss */
}
else
{
/* vv does not contain xx */
}
private static List<String> vv = new ArrayList<String>();
vv.add("area");
vv.add("base");
vv.add("basefont");
vv.add("br");
vv.add("col");
vv.add("frame");
vv.add("hr");
vv.add("img");
vv.add("input");
vv.add("isindex");
vv.add("link");
vv.add("meta");
vv.add("param");
String ss = "hr";
if (vv.contains(ss))
{
/* vv contains ss */
}
else
{
/* vv does not contain xx */
}
==> Store apps C++/CX
Platform::Collections::Vector<Platform::String^>^ vv = ref new Vector<Platform::String^>();
vv->Append("area");
vv->Append("base");
vv->Append("basefont");
vv->Append("br");
vv->Append("col");
vv->Append("frame");
vv->Append("hr");
vv->Append("img");
vv->Append("input");
vv->Append("isindex");
vv->Append("link");
vv->Append("meta");
vv->Append("param");
unsigned int index = 0;
String^ ss = "hr";
if (vv->IndexOf(ss, &index))
{
/* vv contains ss */
}
else
{
/* vv does not contain xx */
}
2014年1月6日 星期一
[Windows 8] Fixed: error LNK2001: unresolved external symbol _CLSID_FreeThreadedXMLHTTP60
Add msxml6.lib into Project\Properties\Configuration\Properties\Linker\Input\Additional Dependencies
[Windows 8] Fixed: error LNK2019: unresolved external symbol _CreateStreamOverRandomAccessStream@12 ...
Add shcore.lib into Project\Properties\Configuration\Properties\Linker\Input\Additional Dependencies
[Windows 8] Fixed: error C2061: syntax error : identifier 'task'
1. #include <ppltasks.h>
2. using namespace Concurrency;
2014年1月1日 星期三
[Windows 8] How to show ... when string is long in textBlock.
Add TextTrimming="WordEllipsis" in XAML
[Windows 8] How to covert Platform::String to char and fix C2440 Error with C++
Covert Platform::String to char
Platform::String ^SrcString = "abc";
std::wstring tmpW(SrcString ->Begin());
std::string tmpA(tmpW.begin(), tmpW.end());
char* DstString = tmpA.c_str(); // Error C2240
Platform::String ^SrcString = "abc";
std::wstring tmpW(SrcString ->Begin());
std::string tmpA(tmpW.begin(), tmpW.end());
char* DstString = tmpA.c_str(); // Error C2240
fix C2440 Error
Platform::String ^SrcString = "abc";
std::wstring tmpW(SrcString ->Begin());
std::string tmpA(tmpW.begin(), tmpW.end());
const char* DstString = tmpA.c_str();
std::string tmpA(tmpW.begin(), tmpW.end());
const char* DstString = tmpA.c_str();
[VC++] 如何在Edit control移動編輯位置至最後一行加入文字
TCHAR tmp[MAX_PATH];
ZeroMemory(tmp, sizeof(TCHAR) * MAX_PATH);
wsprintf(tmp, L"[Count]: %d\r\n", nCount);
m_oResult.SetSel(0, -1);
m_oResult.SetSel(-1);
m_oResult.ReplaceSel(tmp);
ZeroMemory(tmp, sizeof(TCHAR) * MAX_PATH);
wsprintf(tmp, L"[Count]: %d\r\n", nCount);
m_oResult.SetSel(0, -1);
m_oResult.SetSel(-1);
m_oResult.ReplaceSel(tmp);
[Win32] 如何列印 %f 的資訊
先用ANSI code function, 再轉成Unicode, 如下:
char tmp[MAX_PATH];
ZeroMemory(tmp, sizeof(char) * MAX_PATH);
sprintf_s(tmp, "[Time Elapsed]: %f sec\n", dwTimeElapsed / 1000.0);
TCHAR tmp1[MAX_PATH];
ZeroMemory(tmp1, sizeof(TCHAR) * MAX_PATH);
wsprintf(tmp1, L"%S", tmp);
OutputDebugString(tmp1);
char tmp[MAX_PATH];
ZeroMemory(tmp, sizeof(char) * MAX_PATH);
sprintf_s(tmp, "[Time Elapsed]: %f sec\n", dwTimeElapsed / 1000.0);
TCHAR tmp1[MAX_PATH];
ZeroMemory(tmp1, sizeof(TCHAR) * MAX_PATH);
wsprintf(tmp1, L"%S", tmp);
OutputDebugString(tmp1);
[Android Studio] 如何增加編輯器顯示行數和類別成員的區分
1. Open Settings Dialog in File\Settings...
2. Select IDE Settings\Editor\Appearance
3. Choose "Show line numbers" and "Show member separators"
2. Select IDE Settings\Editor\Appearance
3. Choose "Show line numbers" and "Show member separators"
[Android Studio] How to change the edit font in Android Studio
1. Open Settings Dialog in File\Settings...
2. Select IDE Settings\Editor\Colors & Fonts\Font
3. Press Save As...
4. Input name in popup dialog and Save
5. Remove Selected fonts and select new Available fonts
6. Press OK.
2. Select IDE Settings\Editor\Colors & Fonts\Font
3. Press Save As...
4. Input name in popup dialog and Save
5. Remove Selected fonts and select new Available fonts
6. Press OK.
訂閱:
文章 (Atom)