犯过的一些蠢错

2016-06-22  本文已影响22人  queuey

block直接使用私有变量_property

在代码块中直接访问私有变量相当于self->_property。虽然没有写self,但暗含了对self的retain,造成了循环应用。


解决方案:使用weakSelf/StrongSelf.

UITableViewController如何使用静态Cell

需要在SB中勾选才能使用静态Cell

通过pods引入的库报错

error_AFNetworking.png

解决方案:设置 Project->Info->Configurations,在Configurations里面吧Debug 和Release的Tests 的None改为pods

Paste_Image.png

weakself的写法

** __weak __typeof(&self)weakSelf = self;*
** __weak __typeof(self) weakSelf = self;**
** __weak XxxViewController weakSelf = self;*
** __weak id weakSelf = self;**

这四种写法都是正确的。

通过反向映射会产生警告

//通过反向映射到APP方法中

 messageName = [messageName stringByAppendingString:@":"];
 SEL selector = NSSelectorFromString(messageName);
 if ([self respondsToSelector:selector]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
        [self performSelector:selector withObject:message.body];
#pragma clang diagnostic pop
 }

真机编译时报The file “WeLease.app” couldn’t be opened because you don’t have permission to view it.这个错.

WX20170831-144900@2x.png

解决方案: 将工程中Products文件夹下面对应的.app文件删除即可.

时间格式转化问题

NSString *timeString = [[NSDate date] stringWithFormat:@"yyyy.MM.dd HH:mm:ss"];
这里采用yyyy.MM.dd HH:mm:ss 才是标准的,大写的M代表月份,mm代表的为分,如果写错会造成时间错误

上一篇 下一篇

猜你喜欢

热点阅读