Re: Making Array Pointers Global
Re: Making Array Pointers Global
- Subject: Re: Making Array Pointers Global
- From: Charles Bennett <email@hidden>
- Date: Thu, 04 Apr 2002 20:26:36 -0500
If it's in your header file, then your class can see it. That's not likely your problem.
Did you actually alloc the array? What does you code look like where you
init the array? Did you retain it (retain is important..)
I'm wondering if you simply declared a NSArray* in your header..
which leaves you with a pointer that is ready to point to a NSArray
when you get around to allocating one.
I don't know how you are populating the array... if you need it to be mutable or not.. but
if you are init'ing it with known or constant data look at
array = [[NSArray arrayWithObject:"someobject"] retain] or arrayWithObjects...
any of the +array methods at
http://developer.apple.com/techpubs/macosx/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html
and in your dealloc method you can release the array..
Chuck
"Frederick C. Lee" wrote:
>
>
Greetings:
>
I'm trying to populate a set of arrays that can be global within a
>
program/class versus a local within a method. I had thought that if I
>
declare the array pointer (NSArray *) within the header file or at the
>
top of the body file, it would essentially be static as are the simple
>
datatypes like 'int'.
>
>
Apparently that is not true:
>
>
2002-04-04 16:38:02.430 Converter[1959] Inside LoadArrays.
>
2002-04-04 16:38:05.172 Converter[1959] Inside setParameters. myNumber=
>
666
>
>
Converter.app has exited due to signal 10 (SIGBUS).
>
>
In the above case, 'myNumber' is a simple 'int' and declared at the top
>
of the object and can be assessed within any method of the object.
>
But an array (NSArray *) variable appears only to be local within the
>
defined method. Accessing it anywhere else yields the above 'signal 10'
>
error.
>
>
Question: How can I make an array variable STATIC till I dealloc at the
>
end?
>
>
I've used 'extern' & 'static' keywords without success.
>
>
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.
--
UPS Management software for OS X
http://www.powerguardian.com
_______________________________________________
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.