English 中文(简体)
某些人怀疑在ios中是否留下记忆?
原标题:Some doubts about memory-retain in ios applicato?
  1. 是否需要在文稿申请中保留<代码>NSObject?

  2. <代码>retainCount==1,retainCount=2....etc?

  3. 如何处置保留和释放案例的变化?

  4. 何时保留/替换<代码>NSObject,保留一个字面/减少一个字眼,究竟是什么记忆?

最佳回答
  1. Retaining an object indicates that you are taking ownership of that object. So you have to release it once after you are done with it.
  2. retainCount = 1 indicates that it is being strongly referenced from one place. If retainCount = 2, then it is being strongly referenced from two places.
  3. Properties, depending on whether it is a retain, copy or assign property, handles memory management differently
  4. Retain count only tells us how many string references are there for the object. As ling as it is greater than 0, the object is not removed from memory. Once it becomes 0, the obj is removed from memory (dealloc of tht object is called)

EDIT:

  1. If it is a retain property, each time you set a retain property using the . , then the old value is released, new value is retained and assigned to the property. The same happens with copy, just that the new value is sent a copy instead of retain. If it is an assign property, the new value is directly assigned to the property (no release, no retain)
问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签