嗨,我試圖將一個ViewController中的NSString傳遞給NSObject中的NSString。 這裏是我在我的NSObject中使用的代碼來調用字符串並將其傳遞給我的新字符串。將NSString從ViewController傳遞給NSObject
RegisterDeviceViewController *S = [[RegisterDeviceViewController alloc] init];
tempRegCode = S.checkString;
NSLog(@"tempRegCode=%@",tempRegCode);
的問題是,一旦按下視圖上的按鈕啓動該方法在我的NSObject它工作甜但是沒有被傳遞給tempRegCode ..這是我的日誌。
[會話開始於2011-05-03 9時27分35秒+ 1200] 2011-05-03 09:27:36.264 instaCode1.3 [1456:207]百勝百勝餵我更多的cookie! ! func = ERROR 代碼= 1 Text = Please Register Device 2011-05-03 09:27:36.266 instaCode1.3 [1456:207] cookieCode = code1 2011-05-03 09:27:37.983 instaCode1.3 [ 1456:207] alerts.m確定按鈕被按下 2011-05-03 09:27:49.539 instaCode1.3 [1456:207]用戶註冊爲'22222-22222-22222-22222' 2011-05-03 09:27 :49.540 instaCode1.3 [1456:207] tempRegCode =(null)
正如你可以在末尾看到'tempRegCode =(null)??
編輯:: 我這是怎麼傳遞的變量checkString
- (IBAction)submitRegistration:(id)sender{
//NSLog(@"submit Registration button has been pressed");
//add text format here
checkString = regTextField.text;
NSLog(@"Users Registration is '%@'",checkString);
regConnection *Reg= [[regConnection alloc] init];
[Reg startRegConnect];
}
也許你可以展示一個你傳遞值的嘗試的例子嗎?將它作爲方法參數傳遞或設置Property或變量? – 2011-05-02 21:57:24