ソケットによってサーバーから取得する文字列値を格納するグローバル変数を設定しました。ソケットは、次のように 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 では、次のように実装します。
- (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 からは渡されません。そのストリーム デリゲートからこのテキスト フィールドに正しいデータを渡す方法は?