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 10-07-2009, 12:00 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 41
Default setString and Array.. ?

Hello developer.
I've a small problem
I've an array:

PHP Code:
NSMutableArray *my_array = [[NSMutableArray allocinitWithObjects:@"1",@"2",@"3",@"f",@"g",nil];
//And a for cycle
for(int i=0< [my_array count]; i++)
    {
//If a write 
[myLabel setString:[my_array  objectAtIndex:i]];
//myLabel text return is 0,1,2,e,f and no 1,2,3,f,g
}
// 
How to solve this?
Thz
jj
jhoncybpr is offline   Reply With Quote
Old 10-07-2009, 01:25 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Updating a label multiple times in a loop doesn't make sense - you'll only see the last value. If you run your code as-is, I'd expect to see just "g" - only the last item will wind up in the label.

If I run my modified code I see 1,2,3,f,g in the log, so your array is fine:

Code:
    NSMutableArray *my_array = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"f",@"g",nil];
    //And a for cycle
    for(int i=0; i < [my_array count]; i++)
    {
    NSLog(@"item: %@",[my_array  objectAtIndex:i]);
    }
Are you modifying "i" somewhere else? Are you modifying the array somewhere else?
__________________

Free Games!
smasher is offline   Reply With Quote
Old 10-07-2009, 04:08 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 791
Default

There is no setString: in UILabel, maybe just a typo..
nobre84 is offline   Reply With Quote
Old 10-07-2009, 04:23 PM   #4 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 41
Default

Quote:
Originally Posted by nobre84 View Post
There is no setString: in UILabel, maybe just a typo..
Yes, is a typo.
I work with a FontLaber for embed font.
Any solution or alternative?
Thz
jhoncybpr is offline   Reply With Quote
Old 10-07-2009, 05:01 PM   #5 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by nobre84 View Post
There is no setString: in UILabel, maybe just a typo..
Good point. Didn't notice that.

jhoncybpr, I don't know what setString or FontLaber is - you usually use setText: with UILabel. Do you get the right answers when you NSLog? then your array is okay and the problem is in setString.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 10-07-2009, 05:56 PM   #6 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 41
Default

Quote:
Originally Posted by smasher View Post
Good point. Didn't notice that.

jhoncybpr, I don't know what setString or FontLaber is - you usually use setText: with UILabel. Do you get the right answers when you NSLog? then your array is okay and the problem is in setString.
The array is ok. The log is perfect.
jhoncybpr is offline   Reply With Quote
Reply

Bookmarks

Tags
nsmutablearray, setstring

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: 253
23 members and 230 guests
@sandris, ADY, Dani77, diyora, FAED, fredidf, F_Bryant, GHuebner, HDshot, JasonR, mer10, Oral B, prchn4christ, Rudy, smithdale87, Speed, spiderguy84, stekki, tgjorgoski, Thompson22, Touchmint, twerner, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,752
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

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