On Wed, Jul 9, 2008 at 4:12 PM, Kevin Walzer <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm trying to work through an exercise in the new Hillegass book and am
> encountering difficulties. The app fails to build. The relevant code snippet
> is below, with errors noted in the comments:
>
> -(IBAction)getCount:(id)sender
> {
>
>        NSString *string = [textField stringValue];
>        int *stringLength = [string length];  //warning: initialization makes
> pointer from integer without a cast

You've declared stringLength as a pointer to an int, then assigned an
integer value to it. You don't want a pointer here, so leave out he *:

    int stringLength = [string length];

>        [textLabel setStringValue:@"\"[EMAIL PROTECTED]" is %d characters 
> long", string,
> stringLength]; //error: too many arguments to function 'setStringValue:'

The -setStringValue: method takes one and only one argument. In
particular, it does *not* take a format string and a variable argument
list, as you appear to expect it to do. To do something like that, you
need to break it into two steps:

    NSString *newString = [NSString localizedStringWithFormat:
@"\"[EMAIL PROTECTED]" is %d characters long", string, stringLength];
    [textLabel setStringValue: newString];

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to