我想在我的应用程序中创建一些有趣的东西.所以,我创建了一个UILabel,我想输出新值.
所以,我的代码.
NSString *test = @"13";
self.UserAge.text = @"Your age is %@", test;
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
在Console-Command模式下,我可以使用NSLog(); 我的结果是"你的年龄是%@".但我需要输出"你的年龄是13岁".我应该怎么做名字?对不起,如果我的问题很容易.我是初学者.:)
谢谢大家回答我的问题.
我想做以下事情:如果country =="Россия",有些动作..但我的if-else语句不起作用.我该怎么办?提前致谢.我的代码:
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey:NSLocaleCountryCode];
NSString *country = [locale displayNameForKey:NSLocaleCountryCode value: countryCode];
NSLog(@"%@", country);
if (country == @"??????") {
NSLog(@"GO RUSSIA");
}
else {
NSLog(@"You are not russian");
}
Run Code Online (Sandbox Code Playgroud) 所以,在我之前的问题中(查看这个> If-else:NSString)我已经知道如何检查两个字符串.但现在我的任务是比较两个数字.
isEqualToNumber不是我需要的.例如:如果第一个数字的值为13,则第二个值的值为20.如何比较这些数字?
谢谢大家.我应该使用哪种方法?
我的代码:
NSNumber *foo1 = @13;
NSNumber *foo2 = @14;
Run Code Online (Sandbox Code Playgroud)
我需要比较它们:
if ( foo1 < foo2) {
//some actions
}
Run Code Online (Sandbox Code Playgroud)