我已經建立了一個單獨的對象,以我的應用程序無效CFArrayRef問題
@interface MyCommon : NSObject {
NSArray *quizz;
int iCurrentQuestion;
};
+ (MyCommon *)singleton;
@property (retain) NSArray *quizz;
@property (assign) int iCurrentQuestion;
@end
MyCommon.m
#import "MyCommon.h"
// MyCommon.m:
@implementation MyCommon
static MyCommon * MyCommon_Singleton = nil;
@synthesize iCurrentQuestion;
+ (MyCommon *)singleton
{
if (nil == MyCommon_Singleton)
{
MyCommon_Singleton = [[MyCommon alloc] init];
NSLog(@"allocating MyCommon_Singleton at %@",MyCommon_Singleton);
}
else {
NSLog(@"accessing singleton : %@", MyCommon_Singleton);
}
return MyCommon_Singleton;
}
- (NSArray*) getQuizz{
return quizz;
}
- (void) setQuizz:(NSArray *)array {
quizz = [NSArray arrayWithArray:array];
NSLog(@"setQuizz : %@",quizz);
}
沒有爲寫QUIZZ對象(setQuizz)沒有問題,管理一些數據,但是當我嘗試訪問它閱讀,我得到一個崩潰:在QUIZZ看起來無效,Xcode中通知我無效CFArrayRef
我不知道什麼是錯我的代碼。
做你忘了在上面的代碼的東西嗎?我的日誌 – 2011-04-07 15:30:51
@ N-AccessDev遺憾的錯字得到setQuizz(空)。我寫'TMP = [陣列保留]的''代替QUIZZ = [陣列保留]' – Jilouc 2011-04-07 15:35:08
它工作感謝;) – 2011-04-07 15:51:25