所以我有應格式化一個SecondviewController值字符串顯示firstViewController選項卡上的應用程序。數字的arent與十進制樣式格式
當用戶輸入數字,其假設使用逗號每3位進行格式化。但不知何故,我似乎無法得到如何顯示到firstViewController。這裏是我的代碼:
在secondViewController.m
-(IBAction) button:(id)sender{
NSString *string1 = self.addDigitField.text;
/* format the entered digits */
NSNumberFormatter *format = [NSNumberFormatter new];
[format setNumberStyle: NSNumberFormatterDecimalStyle];
NSNumber *n = [format numberFromString: addDigitField];
/* display the string1 value to the firstViewController Label*/
self.string1 = [self. addDigitField text]
FirstViewcontroller *first = self.tabBarController.viewControllers[0];
first.fvcString = self.string1;
}
現在
firstViewController.m
/* display the value into firstViewController label *
-(void) viewDidAppear:(BOOL) animated {
If (self.svcString != nil)
self.displayValue.text = self.svcString;
}
所以我的問題是,在這個代碼做我把消息方法格式化 數量?我試圖添加的代碼如下:
[format stringFromNumber: n];
做這一切時,在一個單一視圖的應用程序通常我用這樣的方式:
self.label.text = [format stringFromNumber: n];
它格式化了。但在我的字符串格式化的firstViewcontroller 從secondViewcontroller的情況是,我失去了,我要去的地方 不對任何建議?