Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tutorials > Tutorial Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 02-13-2011, 12:42 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 1
JoSoap is on a distinguished road
Default Global NSMutableArray

I'm trying my best with Objective-C but I have a small problem I just can't figure out. A little help would be appreciated. I have a Global NSMutableArray (why not a singleton - its a long story). In the same class I have two methods which uses the array. The first method has no problems populating and accessing the array. The other method knows about the array because it too has an 'extern NSMutableArray' declaration but it is empty. I haven't released it so what is happening to the contents of my array?
JoSoap is offline   Reply With Quote
Old 03-09-2011, 09:47 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 14
lord anubis is on a distinguished road
Default

Quote:
Originally Posted by JoSoap View Post
I'm trying my best with Objective-C but I have a small problem I just can't figure out. A little help would be appreciated. I have a Global NSMutableArray (why not a singleton - its a long story). In the same class I have two methods which uses the array. The first method has no problems populating and accessing the array. The other method knows about the array because it too has an 'extern NSMutableArray' declaration but it is empty. I haven't released it so what is happening to the contents of my array?
Of course your given info is sparse, results in not knowing what you have.

Did you:

MYClass.m

static NSMutableArray *myArray;
@implementation MyClass

+ (NSMutableArray *)myArray
{
return myArray;
}

@end

This will uncover the file-scoped array using the myArray class method. Now, if you need to have access to tmyArray, use an extern declaration in your MyClass.h.

extern NSMutableArray *relationshipMatch;

Any source file that #imports MyClass.h will know of the existence
of an NSMutableArray *myArray. The references to this
variable will be available during the linker pass.

check if this works for you [MyClass myArray];

HTH
lord anubis is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, objective c, objective c memory leak

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 175,696
Threads: 94,139
Posts: 402,961
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jasper_muc
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:57 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0