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: Ron Fleckner <email@hidden>
- Date: Mon, 21 Jul 2008 08:27:07 +1000
On 21/07/2008, at 6:26 AM, Phil Faber wrote:
On 20 Jul 2008, at 13:16, Ron Fleckner wrote:
Still struggling with documentation!
That might be because the documentation makes the reasonable
assumption that you already know how to use C and Objective-C.
You're not recognising the difference between the data types 'int'
and 'pointer to object'. The text field expects a pointer to an
NSString. Telling it to setIntValue:someInt is just you hoping
it'll work.
What you need to do is [text2 setStringValue:[NSString
stringWithFormat:@"%d", [text1 length]]];
You should read the documentation, paying attention to method
return types and etcetera. Also, bone up on basic C. It will
help a lot.
I'm trying! Honest! I've studied 'Learn C for Cocoa' at http://
cocoadevcentral.com/articles/000081.php, and a C programming book,
as well as looking up stuff on the Web but it's a very slow
process. The fact that I'm dyslexic doesn't help (although that's
not a good excuse) as I need to go over things again and again to
'get' them ... although once I've 'got it', it tends to stay put!
Getting there. Slowly.
OK, sorry. I think I got out of the wrong side of bed that morning.
As it turns out, the 'solution' I posted was wrong anyway. [text1
length] won't work because an NSTextField doesn't respond to
'length'. It should be [[text1 stringValue] length]
Happy coding,
Ron
_______________________________________________
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