我编译了我的应用程序,我遇到了这个错误 - 命令/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang失败,退出代码为1
加上我想通知用户他要发布的内容。我试过了 -
NSString *someText = textForSharing;
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Confirm" message:(@"Are you sure you want to post %@ on your facebook wall?", *someText) delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
但是它给了我 - 错误:Experession结果未使用和错误:将'NSString'发送到不兼容类型'NSString *'的参数
我该怎么办?提前谢谢!
答案 0 :(得分:1)
从哪里来这个语法?
(@"Are you sure you want to post %@ on your facebook wall?", *someText)
尝试
[NSString stringWithFormat:@"Are you sure you want to post %@ on your facebook wall?", someText];
答案 1 :(得分:1)
首先,表达
(@"Are you sure you want to post %@ on your facebook wall?", *someText)
返回(* sometext)类型(NSString) 但格式修饰符%@需要一个指向对象的指针(“id”,它基本上是指向NSObject的指针)
其次,如果你使用格式,你需要函数/ selctor来解析这种格式(NSLog() or +[NSString stringWithFormat: (NSString*)format]
或c-style sprintf()
等)
答案 2 :(得分:0)
使用stringWithFormat,它将解决不兼容的类型'NSString *'错误。