Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arjit

macrumors newbie
Original poster
Feb 20, 2009
18
0
i have a function
Code:
Code:
// this is the header 
@interface MyClass
{
    theclass * obj;
}


// this is the .m file 
-(void) doSomething{
    obj=[[theclass alloc] init];
}

-(void)something{
    theclass=nil;
    obj=[[theclass alloc] init];
}
so in something function it is getting a bad memory error how do this ?
i need to init the same object again and again ....
how do i do that again ?
any help
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
i have a function
Code:
Code:
// this is the header 
@interface MyClass
{
    theclass * obj;
}


// this is the .m file 
-(void) doSomething{
    obj=[[theclass alloc] init];
}

-(void)something{
    theclass=nil;
    obj=[[theclass alloc] init];
}
so in something function it is getting a bad memory error how do this ?
i need to init the same object again and again ....
how do i do that again ?
any help

In your "something" method, you're assigning nil to the class itself rather than to your instance of the class ("obj").
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.