• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Why my object becomes invalid ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why my object becomes invalid ?


  • Subject: Why my object becomes invalid ?
  • From: "kubernan @ 10191 Tec." <email@hidden>
  • Date: Sat, 9 Aug 2003 03:09:40 +0200

Hello,

I read again and again the retain/release rules but i always have a
"strange"
behavior that causes a crash (signal 10).

In the -(id)init method of my main class i allocate a string :
(not compiled code)

@interface myClass : NSObject
{
NSString *myString
}

-(id)init
{
self= [super init];

myString = [[NSString alloc] init];
myString = [myString stringByAppendingString:@"test"];
return self;

}

-(void)myTestMethod
{
// the first time this method is called there is no problem
// with the second call, i have a crash on myString object
// there is no manipulation on myString between the first and second
call

NSLog([myDict objectForKey:@"theKey"]); // <- always gives something
NSLog(myString); // first time is OK, second call --> crash
[anOtherClass doSomethingWithTheParameter:[myString
stringByAppendingString:[myDict objectForKey:@"theKey"]]];
}

Is it possible that [myString stringByAppendingString:[myDict
objectForKey:@"theKey"]] as argument of the method
of anOtherClass makes something on myString object itself ?

Thx for your help.
K.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Why my object becomes invalid ?
      • From: "David W. Halliday" <email@hidden>
    • Re: Why my object becomes invalid ?
      • From: Cameron Hayne <email@hidden>
  • Prev by Date: Re: compress/decompress - gzip and gunzip using cocoa
  • Next by Date: Re: Loading 2 classes with same name
  • Previous by thread: Re: simple Python shell
  • Next by thread: Re: Why my object becomes invalid ?
  • Index(es):
    • Date
    • Thread