In the AppDelegate, I'm alloc'ing an instance defined in a static library. This instance has an NSString property set a "copy". When I access the string property on this instance, the app crashes with 'unrecognized selector sent to instance'. Xcode provides a code hint for the property, which means it is known in the calling app. The particular class is compiled into the static library target. What am I missing?
Adding some code.
//static library
//ClassA.h
@interface ClassA : NSObject {
...
NSString *downloadUrl;
}
@property(nonatomic, copy) NSString *downloadUrl;
//ClassA.m
@synthesize downloadUrl;
In the calling app's appDelegate.
//app delegate header file
@interface myApp : NSObject <UIApplicationDelegate> {
ClassA *classA;
}
@property (nonatomic, retain) ClassA *classA;
//app delegate .m file
@synthesize classA;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
classA = [[ClassA alloc] init];
//exception occurs here. downloadUrl is of type NSCFNumber
classA.downloadUrl = @"http://www.abc.com/";
...}
Other classes in the app will get a reference to the delegate and call classA.downloadUrl.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…