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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 09-21-2009, 03:39 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Australia
Posts: 180
Default NSMutableArray replaceObjectAtIndex

im trying to replace an object inside a nsmutablearrayA (self) with another nsmutablearrayB, but someone when i tried to access the nsmutablearrayB inside of my nsmutablearrayA (self), it returns nil.

i have no idea why it returns nil, here is my code.

I have a nsmutablearray, each contents one UIImage object.

Code:
NSMutableArray *tempStoredPreviewImageArray = [[NSMutableArray alloc] init];
	for (int i = 0; i < [[self videoDataArray] count]; i++) {
		[tempStoredPreviewImageArray addObject:[UIImage imageNamed:@"emptypreview2.png"]];
	}
	[self setStoredPreviewImageArray:tempStoredPreviewImageArray];
	[tempStoredPreviewImageArray release];

then i call this methods sometime in my app

Code:
[[self storedPreviewImageArray] replaceObjectAtIndex:[index row] withObject:[self arrayOfImages]];

[[self tempAnimationImages] removeAllObjects];
then i tried to read it storedPreviewImageArray

Code:
NSLog(@"%i", [[[self storedPreviewImageArray] objectAtIndex:0] count]);
then the log says
Code:
2009-09-22 03:37:26.252 xx[3091:20b] 0

why did my nsmutablearray object disappear?
svveet is offline   Reply With Quote
Old 09-21-2009, 08:54 AM   #2 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default

This line...confuses me
Code:
[[self storedPreviewImageArray] replaceObjectAtIndex:[index row] withObject:[self arrayOfImages]];
If you have an array of UIImage objects, why are you trying to replace one of the UIImage items with an array of images (arrayOfImages)?

Code:
[[self storedPreviewImageArray] replaceObjectAtIndex:[index row] withObject:[[self arrayOfImages] objectAtIndex:0]];
Dutch is offline   Reply With Quote
Old 09-21-2009, 07:50 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Australia
Posts: 180
Default

Quote:
Originally Posted by Dutch View Post
This line...confuses me
Code:
[[self storedPreviewImageArray] replaceObjectAtIndex:[index row] withObject:[self arrayOfImages]];
If you have an array of UIImage objects, why are you trying to replace one of the UIImage items with an array of images (arrayOfImages)?

Code:
[[self storedPreviewImageArray] replaceObjectAtIndex:[index row] withObject:[[self arrayOfImages] objectAtIndex:0]];
Thanks for your reply, what i am trying to do is replace an UIImage with an Array of UIimages. so i can set animationImages with an array
svveet is offline   Reply With Quote
Old 09-21-2009, 07:54 PM   #4 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by svveet View Post
Thanks for your reply, what i am trying to do is replace an UIImage with an Array of UIimages. so i can set animationImages with an array
I didnt think you can mix and match like that, can you? If so thats pretty cool.
Dutch is offline   Reply With Quote
Old 09-21-2009, 08:28 PM   #5 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 91
Default

I'm sure you've tried all of this, but anyway...

Does this -
Code:
NSLog(@"%i",[arrayOfImages count];
return the number you're expecting?

And what if you try replaceObjectAtIndex:0 , rather than [index row].

Just trying to debug it.
Fool is offline   Reply With Quote
Old 09-21-2009, 08:46 PM   #6 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Australia
Posts: 180
Default

Hi all,

thanks for all the feedbacks, i have managed to solved it by transforming the nsmutablearray into nsarray and then replace with nsarray instead of nsmutablearray.

Code:
NSArray *temparrayAnimationImages = [NSArray arrayWithArray:[self tempAnimationImages]];
[[self storedPreviewImageArray] replaceObjectAtIndex:[[indexPathArray objectAtIndex:0] row] withObject:temparrayAnimationImages];
then it returns the right array.

somehow you cant replace with a nsmutablearray
svveet is offline   Reply With Quote
Reply

Bookmarks

Tags
nsmutablearray, replace

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: 272
17 members and 255 guests
ADY, Alsahir, Dani77, Desert Diva, Duncan C, F_Bryant, Grinarn, HemiMG, Herbie, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, smethorst, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,761
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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