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 Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-31-2010, 12:12 AM   #1 (permalink)
New iPhone-iPad Developer
 
Join Date: May 2010
Posts: 24
JuanMazuera is on a distinguished road
Default NSArray (NSFileManager) to NSMutableArray

Hi, i've been looking for a solution for this but i find no answer, i've tried a lot of thing but nothing works.

im getting an array with the files on a folder with the code

Code:
		NSArray *files = [[NSFileManager defaultManager] directoryContentsAtPath:path];
and trying to load that files to another array to replace:

Code:
		//NSArray * images = [NSArray arrayWithObjects:[UIImage imageNamed:@"1.jpg"], [UIImage image:@"2.jpg"], [UIImage image:@"3.jpg"], [UIImage image:@"4.jpg"], [UIImage image:@"5.jpg"], [UIImage image:@"6.jpg"], nil];
with something like:
(Editwith these 3 option not at the same time))

Code:
NSArray * images = [NSArray arrayWithArray:files];

NSMutableArray * images = [[NSMutableArray alloc]init];
[images arrayByAddingObjectsFromArray:files];

NSMutableArray * images = [[NSMutableArray alloc]initWithArray:files];
but with these 3 options the app crash or the array is empty, can somebody help? thanks!

Edit: the array "files", does have a count different to 0, it reads ok the files from the folder.

Last edited by JuanMazuera; 07-31-2010 at 12:18 AM.
JuanMazuera is offline   Reply With Quote
Old 07-31-2010, 01:27 AM   #2 (permalink)
Pro. Game Developer
iPhone Dev SDK Supporter
 
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 2,176
Kalimba is on a distinguished road
Default

See if this works:
Code:
NSMutableArray * images = [[NSMutableArray alloc] init];
[images addObjectsFromArray:files];
__________________
~~ Word Flurry ~~ App Store / Website / Facebook
Kalimba is offline   Reply With Quote
Old 07-31-2010, 09:22 AM   #3 (permalink)
New iPhone-iPad Developer
 
Join Date: May 2010
Posts: 24
JuanMazuera is on a distinguished road
Default

Quote:
Originally Posted by Kalimba View Post
See if this works:
Code:
NSMutableArray * images = [[NSMutableArray alloc] init];
[images addObjectsFromArray:files];
Thanks for your help, but it's still crashing. I don't know what to do.
the "files" array get the files from a folder containing jpg files. ay other idea?

Edit: if i use the option:

Code:
NSMutableArray * images = [[NSMutableArray alloc]init];
[images arrayByAddingObjectsFromArray:files];
the "images" array has a count of 0, but doesn't crash, but for all the other options the app crash!

Last edited by JuanMazuera; 07-31-2010 at 09:28 AM. Reason: add info
JuanMazuera is offline   Reply With Quote
Old 07-31-2010, 09:41 AM   #4 (permalink)
Pro. Game Developer
iPhone Dev SDK Supporter
 
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 2,176
Kalimba is on a distinguished road
Default

You're going to have to post the code that's crashing.
__________________
~~ Word Flurry ~~ App Store / Website / Facebook
Kalimba is offline   Reply With Quote
Old 07-31-2010, 10:58 AM   #5 (permalink)
New iPhone-iPad Developer
 
Join Date: May 2010
Posts: 24
JuanMazuera is on a distinguished road
Default

Quote:
Originally Posted by Kalimba View Post
You're going to have to post the code that's crashing.
the code that makes my app crash are those 3 on my first post:


Code:
NSArray * images = [NSArray arrayWithArray:files];
Code:
NSMutableArray * images = [[NSMutableArray alloc] init];
[images addObjectsFromArray:files];
Code:
NSMutableArray * images = [[NSMutableArray alloc]initWithArray:files];

with

Code:
NSMutableArray * images = [[NSMutableArray alloc]init];
[images arrayByAddingObjectsFromArray:files];
the app doesn't crash but "images" count is 0.

thanks for your time.

Last edited by JuanMazuera; 07-31-2010 at 10:59 AM. Reason: typo
JuanMazuera is offline   Reply With Quote
Reply

Bookmarks

Tags
array, nsarray, nsdefaultmanager, nsmutablearray, sdk

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
» Online Users: 335
15 members and 320 guests
appservice, bignoggins, dermotos, Domele, EXOPTENDAELAX, guusleijsten, Hamad, heshiming, linkmx, Objective Zero, Paul Slocum, Rudy, Sloshmonster, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

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