但这取决于你如何称你的控制者:
- in an instance variable of an other object : you have to release it in this object s deallocate methode
- in a function : you should release it when you do not need it anymore (retained by another object for example or it finished the job in this function), if you want to return it, just sent the message "autorelease" to it and the NSAutoReleasePool will do the job for you.
为了分配价值,你可以
- set the mutable array with the setParam:(*NSMutableArray)theArrayYouWantToReplaceYourArrayWith
- access it directly with [[yourSampleController param]addObject:(id)objectYouWantToAdd]...
- or more convenient : [yourSampleController.param addObject:(id)objectYouWantToAdd]
添加目标:这里的信息是一个例子,你可以看到在NSMutable Array类参考中修改阵列(移动、分类、......)的方法。
由于你是国家安全局,而不是国家安全委员会,你无法改变你的影响力,但你可以接触。
- [yourSampleController getParam]
- [yourSampleController param]
- yourSampleController.param
If you want to avoid leaks in general, build your project with the Instrument tool in leak mode and look at the objects that are leaked if you found some that are declared in your functions.
You can also check the Clang Static Analyzer (free static debugger) which is quite good if you have a lot of files.
我希望我能帮助你。
Julien