Re: Set string value
Re: Set string value
- Subject: Re: Set string value
- From: Ken Thomases <email@hidden>
- Date: Wed, 9 Jul 2008 15:23:32 -0500
In addition to what Alex said...
On Jul 9, 2008, at 3:12 PM, Kevin Walzer wrote:
-(IBAction)getCount:(id)sender
{
NSString *string = [textField stringValue];
int *stringLength = [string length]; //warning: initialization
makes pointer from integer without a cast
This declares stringLength as a pointer to an int. You don't want it
to be a pointer, it should just be an int. So, remove the asterisk.
For somebody learning C and Objective-C at the same time, it can be
confusing. On the one hand, most Objective-C objects are stored into
explicit pointer variables (except "id" where the pointerness is
implicit). On the other hand, many of the C standard types are not
pointers to objects -- they are just "scalars". I think you need to
review the basics of C.
[textLabel setStringValue:@"\"%@\" is %d characters long", string,
stringLength]; //error: too many arguments to function
'setStringValue:'
NSLog(@"%@", string);
}
Cheers,
Ken
_______________________________________________
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