所以我有应格式化一个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的情况是,我失去了,我要去的地方 不对任何建议?