我設置了一個全局變量存儲從服務器獲取的字符串值。 和插座是如下面的appdelegate impletement:從appdelegate傳遞全局變量返回null
在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是在代理內部設置的值,那麼它不會通過deletegate。 如何將正確的數據從該流代理傳遞到此文本字段?
看起來像'LTField'問題。 –
不,LTField正在工作,如果我設置它LTField.text = @「abc」; – STANLEY
你已經打印出了'sn1',打印出'appDel.sn',或者設置了一個斷點並且通過調試器逐步完成。 – Kevin