码迷,mamicode.com
首页 > 其他好文 > 详细

血泪史

时间:2014-07-28 16:55:24      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:style   color   os   strong   io   for   cti   ar   

记录iOS开发生涯中,因知识库不完备、知识点不清晰,导致的各种坑。

1.You cannot remove objects from array while fast-enumerating it:

numeration is “safe”—the enumerator has a mutation guard so that if you attempt to modify the collection during enumeration, an exception is raised.

Anyway why do you need to change you container while enumerating it? Consider storing elements that need to be deleted and remove them from your container using removeObjectsInArray: or removeObjectsAtIndexes: method.


2.In NSCoding,You cannot encode an NSValue object while wrapping CLLocationcoordinate2D variable:

According to the documentation of the NSKeyedArchiver class,

A keyed archive differs from a non-keyed archive in that all the objects and values encoded into the archive are given names, or keys.

In order to archive elements of a structand give keys to them NSKeyedArchiver would need metadata to know where each field of a struct is located, and what are the names of these fields. The @encode stored with NSValue gives it enough information about the layout of a struct, but the information about the names of each field is missing.

Since there is no metadata about the names of the fields in a struct, it would be impossible to archive the data in such a way as to ensure proper un-archiving. That is why NSKeyedArchiver must refuse to archive NSValues with embedded C structs.



血泪史,布布扣,bubuko.com

血泪史

标签:style   color   os   strong   io   for   cti   ar   

原文地址:http://my.oschina.net/notting/blog/295504

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!