iphone - Objective-c pointers -


i don't know how delete pointer not object, example: have class:

@interface model : nsobject { nsmutablearray *tab; } 

and when this:

model1 = [[model alloc]init]; nsmutablearray * tab2 = [model1 tab]; ... operations ... 

i want delete pointer tab *tab2, when i'm releasing tab2, tab releasing too. in c++ when i'm clearing this:

int =10; *w = &a; 

and when i'm deleting pointer

delete w; 

and variable still in memory , that's ok. should in obj-c delete pointer?

in situation objective-c, there's no reason delete pointer. let fall out of scope. you're not allocating new objets. you're not making copy of tab. you're not retaining it. you're creating pointer original tab object. if like, can set tab2 = nil doesn't matter either way.

in second c++ example, i'm not certain, you're falling undefined behavior because of fact code example gave works on compiler tested! not valid c++ delete pointer not created new.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -