首页 > 分享 > iPhone实例学习之iphone sdk2.0 miss和invalid operands to binary问题

iPhone实例学习之iphone sdk2.0 miss和invalid operands to binary问题

最新推荐文章于 2021-10-05 18:34:18 发布

lego2816 于 2011-08-29 15:24:35 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

 

 这些天在学习iPhone软件开发,在学习到31个iphone软件开发实例教程的时候,首先遇到的是iphone sdk 2.0 miss的问题,我用的是Xcode3.23,it's for Mac OS X10.6 and iPhone OS 4.0。编译下载下来的软件的时候出现错误提示:error: There is no SDK with the name or path 'iphoneos2.0'。

解决的办法是:

1.选择 xCode目录中的"Project".
2.选择 "Edit Project Settings" 子目录.
3.在 "Base SDK for All Configurations"选项中选择iPhone Simulator 4.0.
4.build and run.

但是这个时候编译第一个例程又弹出如下错误:

error: invalid operands to binary - (have 'int' and 'id')

将这段出错代码

NSDate* now = [NSDate date];

int hour = 23 - [[now dateWithCalendarFormat:nil timeZone:nil] hourOfDay];

int min = 59 - [[now dateWithCalendarFormat:nil timeZone:nil] minuteOfHour];

int sec = 59 - [[now dateWithCalendarFormat:nil timeZone:nil] secondOfMinute];

countdownLabel.text = [NSString stringWithFormat:@"%02d:%02d:%02d", hour, min,sec];

 

替换成如下代码即可顺利通过编译:

NSDate* now = [NSDate date];

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSDateComponents *dateComponents = [gregorian components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:now];

NSInteger hour = [dateComponents hour];

NSInteger minute = [dateComponents minute];

NSInteger second = [dateComponents second];

[gregorian release];

countdownLabel.text = [NSString stringWithFormat:@"%02d:%02d:%02d", hour, minute, second];

相关知识

iphone
摄影师实例讲解 如何用iPhone拍宠物
龙之气息iPhone/iPad版下载 v1.01
摄影师实例讲解 如何用iPhone拍宠物(2)
iPhone 7袭来 苹果iPhone 6S跌至3495元
iphone吧
如何利用iPhone拍摄家庭宠物 利用iPhone拍摄家庭宠物技巧
参与 Apple Shot on iPhone 摄影大赛,分享你用 iPhone 拍摄的微距佳作
iphone计算器过程怎么不显示
10 款 iPhone 最佳动物壁纸

网址: iPhone实例学习之iphone sdk2.0 miss和invalid operands to binary问题 https://m.mcbbbk.com/newsview822408.html

所属分类:萌宠日常
上一篇: 宠物店当学徒真实感受!好累!
下一篇: 辽宁职业学院宠物养护与驯导专业现