开发学院手机开发iPhone 开发 iphone/ipad ios cocoa object-c 近期苹果UI部分小... 阅读

iphone/ipad ios cocoa object-c 近期苹果UI部分小结

 2010-12-19 07:19:42 来源:WEB开发网   
核心提示:即可关于这个问题的介绍:http://cocoadevcentral.com/d/learn_objectivec/We can also use this to improve our dealloc method slightly:- (void) dealloc { self.caption = nil; sel
即可

--------------------------------------------

关于这个问题的介绍:http://cocoadevcentral.com/d/learn_objectivec/

We can also use this to improve our dealloc method slightly:

- (void) dealloc { self.caption = nil; self.photographer = nil; [super dealloc]; }

This works because when we set nil as an instance variable, the setter just retains nil (which does nothing) and releases the old value. This approach is often better for dealloc because there's no chance of the variable pointing at random data where an object used to be.

Note that we're using the self. syntax here, which means we're using the setter and picking up the memory management for free. If we just directly set the value like this, there would be a memory leak:

// incorrect. causes a memory leak.

// use self.caption to go through setter

caption = nil;

---------------------------------------------

ps:最近搞了近一个多月的苹果开发,主要负责界面部分。之前并没接触过苹果,这次又算是一次全新的尝试。(从工作以来一直就是在不停的接触新东西,新知识,现在还真不知道这是算好算坏)。最近工作也不是很给力了,大概是没有目标了吧,手头的活干完后自己也全然不会有别的想法了,所以一旦闲下来人就比较颓了。

还得自己挖坑找点事做,不然这样漫无目的的生活未免太无聊乏味了。感觉自己最近几个月思考得太少了,总是被动的等待,没有自己主动的思考判断,这是需要调整的地方。

多思考,多总结,快乐成长!

上一页  1 2 

Tags:iphone ipad ios

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接