• 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
Global Arrays: consider 'autorelease' feature
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Global Arrays: consider 'autorelease' feature


  • Subject: Global Arrays: consider 'autorelease' feature
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Thu, 4 Apr 2002 17:05:44 -0800

Greetings:
I had asked why I'm getting a 'Signal 10' error when I tried to
access an Array variable that was declared in the header or top of the
object-class body, when simple datatypes have no problem.

I've done some research via Archives and found the following tidbit
of information:



> What's the differerence between two?
>
> Both array1 and array2 are locally instantiated in a method.
>
> -(void) doSomething {
> NSArray* array1;
> NSArray* array2;
>
> array1 = [[NSArray arrayWithObjects:s1,s2,s3,s4,nil] autorelease];
> array2 = [[[NSArray alloc] initWithObjects:s1,s2,s3,s4,nil]
> autorelease];
> ...
> }
>
> I'm getting signal raised with array1. but array2 work fine.
>

I had populated the array variable with the 'arrayWithObjects' versus
'alloc; & 'initWithObjects'. The 'arrayWithObjects' does an
'autorelease' within the method and hence, is released prior to
accessing it elsewhere, hence the <signal 10> error.

Simply by using 'array2' method, I'm able to access the particular array
variable elsewhere in the program (object).
Although I must be be sure to RELEASE it at dealloc time.

Ric.
_______________________________________________
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: why Obj-C
  • Next by Date: qt components
  • Previous by thread: Re: why Obj-C
  • Next by thread: Re: Global Arrays: consider 'autorelease' feature
  • Index(es):
    • Date
    • Thread