【发布时间】:2010-09-30 17:42:11
【问题描述】:
这是我正在使用的代码,稍后查看我的错误
@interface MyAppDelegate : NSObject {
NSString *userName;
}
@property (nonatomic, retain) NSString *userName;
...
@end
在 App Delegate 的 .M 文件中,您可以编写:
@implementation MyAppDelegate
@synthesize userName;
...
@end
然后,每当你想获取或写入用户名时,你会写:
MyAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
someClass.someString = appDelegate.userName; //..to fetch
appDelegate.userName = ..some NSString..; //..to write
警告:类型“id”不符合“MyAppDelegate”协议
我的代码中缺少什么?
【问题讨论】:
标签: iphone xcode iphone-sdk-3.0