我从以下行获得"格式字符串不是字符串文字"警告
NSString *formattedString = [[NSString alloc] initWithFormat:format arguments:valist];
Run Code Online (Sandbox Code Playgroud)
我在以下功能中使用它
- (void)logMessage:(NSString *)format
level:(LoggingLevel)level
withParameters:(va_list)valist {
if (level >= self.loggingLevel) {
NSString *formattedString = [[NSString alloc] initWithFormat:format arguments:valist];
}
Run Code Online (Sandbox Code Playgroud)
知道如何解决这个问题吗?我正在使用Xcode 4.6.3
有没有办法在 iOS 上将图像添加到操作表?与苹果在应用商店或苹果音乐应用上所做的一样。我对苹果文档的基本搜索表明我没有在操作表中子类化或添加子视图。
“UIActionSheet 不是为子类化而设计的,您也不应该向其层次结构添加视图。” -- 苹果文档
我想将我的本地日期([NSDate日期])转换为GMT以创建JSON字符串(/ Date(1324435876019-0000)/).
当我将时钟设置为EST时区时,我的代码工作正常,当我将时区更改为PST时,我的代码仍然充当EST.你能告诉我代码是什么问题吗?
NSDate *localDate = [NSDate date];
NSTimeInterval timeZoneOffset = [[NSTimeZone systemTimeZone] secondsFromGMT]; // You could also use the systemTimeZone method
NSTimeInterval gmtTimeInterval = [localDate timeIntervalSinceReferenceDate] - timeZoneOffset;
NSDate *gmtDate = [NSDate dateWithTimeIntervalSinceReferenceDate:gmtTimeInterval];
NSString *time = [NSString stringWithFormat:@"/Date(%@-0000)/", [NSNumber numberWithLongLong:[gmtDate timeIntervalSince1970] * 1000]];
Run Code Online (Sandbox Code Playgroud) 你能告诉我哪种方式正确,为什么在非ARC世界.
+ (NSString *)getUUID {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return [(NSString*) string autorelease];
}
Run Code Online (Sandbox Code Playgroud)
要么
+ (NSString *)getUUID {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return (NSString*)string;
}
Run Code Online (Sandbox Code Playgroud) 什么是(void)sender;在下面的代码呢?我无法理解该表达式的用途.
- (IBAction)signIn:(id)sender {
(void)sender;
[self dismissKeyboardIfNeeded];
}
Run Code Online (Sandbox Code Playgroud) ios ×5
objective-c ×4
iphone ×2
swift ×2
arguments ×1
casting ×1
clang ×1
nsdate ×1
nstimezone ×1
uiview ×1