다음 코드를 실행하면 실패합니다. 내 .H 파일 다음하는 .m 파일에정적 객체의 멤버를 초기화하는 iOS가 실패합니다.
@interface OutlineManager : NSObject
{
NSMutableArray* mOutlines;
}
@property(nonatomic,strong)NSMutableArray* Outlines;
+(void)initialize;
@end
static OutlineManager* outlnManager;
: 난 (무효) 내가 코멘트를 넣어 경우 섹션에서 응용 프로그램이 충돌을 초기화를 실행하지만 때
#import "OutlineManager.h"
@implementation OutlineManager
@synthesize Outlines = mOutlines;
+(void)initialize
{
outlnManager = [[[OutlineManager superclass]alloc]init];
if(outlnManager)
{
outlnManager.Outlines = [[NSMutableArray alloc]init]; //it crashes here
}
NSLog(@"OUTLINEMANAGER INITIALIZED");
}
@end
내가 돈 't 왜 그런지 알 겠어. 이처럼 정적 인 객체의 배열을 초기화 할 수 없는가?
나는 아주 기본적인 것 같지만, Obj C/iOS에서 꽤 새로 나온다.
당신의 도움! 감사합니다
, ZOLI
! 그러나 거기에 널 때문에 다른 .m 파일에 outlnManager.Outlines 개체를 추가 할 수 없습니다. 언제 그것이 null이됩니다. ARC가 무료로 제공합니까? –