Re: Obtaining the number of characters in a string
Re: Obtaining the number of characters in a string
- Subject: Re: Obtaining the number of characters in a string
- From: Andy Lee <email@hidden>
- Date: Sun, 20 Jul 2008 09:41:14 -0400
On Jul 20, 2008, at 8:12 AM, Tim Isted wrote:
Try using
[text2 setStringValue:[NSString stringWithFormat:@"%i",
[[textField1 stringValue] length]]];
Using setIntValue on a text field won't set the text field's
stringValue to be a string from that int.
I believe this is incorrect. Try simply
[text2 setIntValue:[[text1 stringValue] length]];
The original mistake was using [text1 length], which asks the text
*field* for its length (no such method) instead of asking the text
field's *string*.
Using +stringWithFormat: works too, but it's doing more than you need.
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden