Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Set UITextField from NSArray

roberthuttingerroberthuttinger Posts: 96Registered Users
edited July 2011 in iPhone SDK Development
I have tried many variations with no luck. I can NSLog the array and I get this:
[HTML]2011-07-17 00:54:54.886 Widgets[13444:207] (entity: Widget; id: 0x5e0d8e0 ; data: {
success = 1;
coconutscarried = nil;
name = "African Swallow";
uidnumber = "105 ";
})[/HTML]

How can I simple set a text field?

Pardon the mess but this is an assortment of code I have tried (messy). The array and text field have been set up in .h/m and bound in IB

- (void)viewDidLoad {
[super viewDidLoad];
//NSLog(@\"%@\",[[swallowArray name] text]); // doesnt work
//NSLog(@\"The string at index is %@.\", [self.swallowArray objectAtIndex:0]);//nope...
for (int i = 0; i < [swallowArray count]; i++) {
//nameTextField.text = [[swallowArray objectAtIndex:i] uidnumber];
//NSLog(@\"%@\",swallowArray.name);
//}
//nameTextField.text = [[swallowArray objectAtIndex:0] uidnumber];
//NSString* strRate = [[swallowArray object] uidnumber];
nameTextField.text = [nameTextField.text stringByAppendingString:[NSString localizedStringWithFormat:@\", %@\", [[swallowArray objectAtIndex:i] name]]];

}


and many more. This has got to be dead simple, but I am kind of a noob.

thanks!

bo
Post edited by roberthuttinger on

Replies

  • roberthuttingerroberthuttinger Posts: 96Registered Users
    edited July 2011
    ANSWER:

    NSString *nameFromArray = [NSString stringWithFormat:@\"%@\", [eventArray valueForKey:@\"name\"]];
    NSLog(@\"%@\", nameFromArray);
    roberthuttinger;355656 said:
    I have tried many variations with no luck. I can NSLog the array and I get this:
    [HTML]2011-07-17 00:54:54.886 Widgets[13444:207] (entity: Widget; id: 0x5e0d8e0 ; data: {
    success = 1;
    coconutscarried = nil;
    name = "African Swallow";
    uidnumber = "105 ";
    })[/HTML]

    How can I simple set a text field?

    Pardon the mess but this is an assortment of code I have tried (messy). The array and text field have been set up in .h/m and bound in IB

    - (void)viewDidLoad {
    [super viewDidLoad];
    //NSLog(@\"%@\",[[swallowArray name] text]); // doesnt work
    //NSLog(@\"The string at index is %@.\", [self.swallowArray objectAtIndex:0]);//nope...
    for (int i = 0; i < [swallowArray count]; i++) {
    //nameTextField.text = [[swallowArray objectAtIndex:i] uidnumber];
    //NSLog(@\"%@\",swallowArray.name);
    //}
    //nameTextField.text = [[swallowArray objectAtIndex:0] uidnumber];
    //NSString* strRate = [[swallowArray object] uidnumber];
    nameTextField.text = [nameTextField.text stringByAppendingString:[NSString localizedStringWithFormat:@\", %@\", [[swallowArray objectAtIndex:i] name]]];

    }


    and many more. This has got to be dead simple, but I am kind of a noob.

    thanks!

    bo
Sign In or Register to comment.