• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Set string value
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Set string value (From: Kevin Walzer <email@hidden>)

  • Prev by Date: Re: Set string value
  • Next by Date: Re: Making a text cell in a table editable
  • Previous by thread: Re: Set string value
  • Next by thread: Calling autorelease on CFAllocated objects?
  • Index(es):
    • Date
    • Thread