我设置了一个全局变量存储通过套接字从服务器获取的字符串值。并且套接字在appdelegate中实现如下:
在 appdelegate.h 中:
@interface AppDelegate : NSObject <NSStreamDelegate,UIApplicationDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
NSInputStream *inputStream;
NSOutputStream *outputStream;
NSString *sn,*sn1;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, retain) NSInputStream *inputStream;
@property (nonatomic, retain) NSOutputStream *outputStream;
@property (nonatomic, retain) NSString *sn,*sn1;
在 appdelegate.m
@synthesize sn,sn1
然后当传入套接字流委托时,我设置
sn=input
NSLog(@"1st sn: %@",sn);//this sn correct!
然后在 SecondViewControll.m 我设置 sn1=@"hello";
在 FirstViewControll 中,我实现如下: AppDelegate *appDel;
- (void)viewDidLoad
{
[super viewDidLoad];
appDel = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"sn1: %@",sn1);;//this sn correct!
LTField.text=appDel.sn; //this one gives error as below,
}
错误是:
-[__NSCFSet _isNaturallyRTL]: unrecognized selector sent to instance 0x5f87580
2013-06-23 22:49:26.038 test[2987:12c03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet _isNaturallyRTL]: unrecognized selector sent to instance 0x5f87580'
我不知道为什么最后一行给出错误但上一行得到正确的值?我猜这是因为 sn 是在委托中设置的值,然后它不会从删除门中传递出去。如何从该流委托将正确的数据传递给该文本字段?