Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 18, 2013, 07:48 PM   #1
larswik
macrumors 65816
 
Join Date: Sep 2006
NSArray to NSMutableArray

Just had a quick question.

I have a method in a Class that sorts an array, gets information and then returns an NSArray with this code.
Code:
NSMutableArray *itemsFromSkill = [BoilerPlateCode returnItemsForSkill:itemStringLabel withItemList:skillsListDict];
I discovered that I need to add object to the new array called "itemsFromSkill" so I changed it to an NSMutableArray. Should I go back to the method that sorts and returns an NSArray and have it return an NSMutableArray, or does it matter?

I remember a while back reading something about this and this is not the correct way but I can't remember? I think I would need to convert an NSArray to an NSMutableArray with a method like makeMutableCopy or something.

It' not a big deal. I was just wondering.

Thanks.
__________________
I know more than yesterday.
Lars
larswik is offline   0 Reply With Quote
Old Feb 19, 2013, 07:32 AM   #2
waterskier2007
macrumors 68000
 
waterskier2007's Avatar
 
Join Date: Jun 2007
Location: White Lake, MI
Send a message via AIM to waterskier2007
Code:
[NSMutableArray arrayWithArray:(NSArray *)]
should work for whatever you need to do.
__________________
2012 Mac Mini, 2.6 GHz, 16GB RAM, 1TB HDD
2.4Ghz 15" Macbook Pro
16 GB iPhone 5 : 32 GB iPhone 4S : 16 GB iPad 3
16 GB Nexus 7 (2012)
waterskier2007 is offline   0 Reply With Quote
Old Feb 19, 2013, 07:40 AM   #3
ArtOfWarfare
macrumors 601
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Of just add [(code that returns a NSArray * here) mutableCopy];
ArtOfWarfare is offline   0 Reply With Quote
Old Feb 19, 2013, 10:10 PM   #4
larswik
Thread Starter
macrumors 65816
 
Join Date: Sep 2006
OK That clears it up. So there is a correct way of doing it. I went a head and convert my method to return an NSMutableArray.

Thanks.
__________________
I know more than yesterday.
Lars
larswik is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Forum Jump


All times are GMT -5. The time now is 10:53 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC