• 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
Re: basic Obj-C lesson (was runtime error with NSArray no
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: basic Obj-C lesson (was runtime error with NSArray no


  • Subject: Re: basic Obj-C lesson (was runtime error with NSArray no
  • From: Bill Bumgarner <email@hidden>
  • Date: Mon, 9 Dec 2002 10:45:00 -0500

There isn't anything in your - (IBAction)swap:(id)sender method that could directly change the retain counts of the contained objects. So, it must be something indirect -- something called by the method.

In particular, this...

[self setStat:stat1 atIndex:stat2i];
[self setStat:stat2 atIndex:stat1i];

... appears to be the only two lines that might do anything that affect retain counts. I'm assuming that -setStat:atIndex: manipulates the contents of an array-- removing the old, inserting the new. When it does this, the old will be released. While that behavior may be correct inside of -setStat:atIndex:, it causes the calling method to explode.

I would suggest doing something like the following.

[stat1 retain];
[stat2 retain];
[self setStat:stat1 atIndex:stat2i];
[self setStat:stat2 atIndex:stat1i];
[stat1 release];
[stat2 release];

b.bum
_______________________________________________
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.

  • Prev by Date: Re: NSTextView scrolling problem...
  • Next by Date: Re: Subject: Re: Cocoa Book
  • Previous by thread: Re: NSTextView scrolling problem...
  • Next by thread: orderOut a sheet while app is hidden
  • Index(es):
    • Date
    • Thread