[__NSCFString timeIntervalSinceNow]问题

问题描述:想计算某一段代码的执行时间,加了下面的代码:

NSDate *startTime;
startTime = [NSDate date];
NSLog(@"Time: %f", -[startTime timeIntervalSinceNow]);

结果报错如下:

[__NSCFString timeIntervalSinceNow]: unrecognized selector set to instance

问题原因很简单,因为startTime没有retain

时间: 2024-07-29 21:43:47

[__NSCFString timeIntervalSinceNow]问题的相关文章

MBProgressHUD -[__NSCFString sizeWithAttributes:]: unrecognized selector问题解决

最近的工作需要将工程打包成静态库文件,然后提供给别人使用.在工程中有引用第三方类库MBProgressHUD,在打包出静态库文件后,写了个Demo,引用了其中的一段代码来显示MBProgressHUD,在iOS 7模拟器中无错运行. 来到真机测试,在iOS 7的设备上无压力通过.但是在iOS 6的设备上显示MBProgressHUD时却崩溃了,错误提示为: -[__NSCFString sizeWithAttributes:]: unrecognized selector sent to XXX

[__NSCFString absoluteURL]错误的解决方案

Xcode提醒错误: -[__NSCFString absoluteURL]: unrecognized selector sent to instance 0x8c4d3a0 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString absoluteURL]: unrecognized selector sent to instance 0x8c4d3a

[__NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x17deba00

还真是一波未平一波又起,又出现了这个问题,详情如下: -[__NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x17deba00 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString countByEnumer

适配iOS7无 [__NSCFString containsString:]:

看到这个错的时候 一般就是iOS系统不兼容的原因 我现在基本没有考虑iOS7的兼容,但有时候又偏偏有iOS7的机子,很无奈又要做适配 我最初写的代码是这样的: if ([self.UserNameTF.text containsString:@"*"]) { GFBLog(@"还有*号 不转换"); } else { if ([self.UserNameTF.text containsString:@"*"] && [UIText

__NSCFString containsString:]: unrecognized selector sent to instance 0x7f876b79e160

If you want your code to work on iOS 7 as well as iOS 8 you should use one of the rangeOfString calls instead. Basically if the range returned has a length of zero, the substring is not there. /* These methods return length==0 if the target string is

OC学习篇之---Foundation框架中的其他类(NSNumber,NSDate,NSExcetion)

1.NSNumber 这个类主要是用来封装基本类型的,说到这里,就不得不说一下了: OC中的集合是不允许存入基本类型的,所以NSNumber类就诞生了,需要将基本类型封装一下,然后存进去,这个类似于Java中的自动装箱和拆箱,Java中的集合其实也是不允许存入基本类型的,但是我们任然看可以那么操作,就是因为有自动装箱功能,如果你将Eclipse的JDK改成5.0之前的,你看看还能操作吗.. 注:那为什么基本类型不能存入到集合中呢? 原因是在操作集合的时候会操作集合元素中的方法,但是基本类型是没有

003-日期与时间(NSDate)

#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { //获取代表当前日期,时间的NSDate NSDate* date1 = [NSDate date]; NSLog(@"%@", date1); //获取从当前时间开始,一天之后的日期 NSDate* date2 = [[NSDate alloc]initWithTimeInterval

iOS中UITableViewCell的重用问题解决方案

UITableViewCell重用 为了能够保证tableViewCell能够高效的执行,Objective-c中引进了重用队列的机制,重影现象也是在重用队列时经常遇到的问题,那么如何解决这个问题呢?下面给出了几种解决办法. 第一种解决方法 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSArray *subViews = cell

疯狂iOS上1

一:iOS应用与开发环境 1.1 OC与iOS简介 1.2 搭建iOS开发环境 1.3 第一个OC程序 1.4 熟悉Xcode 左边导航面板从左到右依次是:项目导航.符号导航.搜索导航.问题导航.测试导航.调试导航.断点导航.日志导航,快捷键是command+1/2 右边检查器面板包括:文件检查器.快速帮助检查器.身份检查器.属性检查器.大小检查器.连接检查器,快捷键是command+option+1/2 右下端库面板包括:文件模板库.代码片段库.对象库.媒体库,快捷键是control+opti