2015年6月12日 星期五

Xcode 編譯錯誤: duplicate symbols for architecture arm64


在編譯的時候編譯失敗,並且查詢錯誤訊息:duplicate symbols for architecture arm64
於是我到專案→Target→Build Phases→Complie Source 卻沒有重複的 .m檔,我將過去的專案設定做比對,發現 Build Setting 的 No common blocks 與先前的專案設定不一樣,改為 No 便可以編譯通過。

Apple Quick Help 解釋 No common blocks:

Declaration:
GCC_NO_COMMON_BLOCKS


Description:
In C, allocate even uninitialized global variables in the data section of the object file, rather than generating them as common blocks.  This has the effect that if the same variable is declared (without extern ) in two different compilations, you will get an error when you link them. [GCC_NO_COMMON_BLOCKS, -fno-common]

2015年6月8日 星期一

2015年5月30日 星期六

繼承至 NSManagedobject 的 Entity 當作一般物件使用

NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Device" inManagedObjectContext:[[WPCoreDataCenter sharedMainCenter] mainManagedObjectContext]];
Device *device = [[Device alloc] initWithEntity:entityDescription insertIntoManagedObjectContext:nil];
device.idnum = @"A845dd7412b56";
device.serial = @"SMACODZL";

2015年2月8日 星期日

亂數產生器

int generateRandomNumberBetweenMin(int min,int max)
{
    return ( (arc4random() % (max-min+1)) + min );
}