Cocoa (too many arguments)

Discussion in 'Mac Programming' started by lostingamma, Apr 4, 2005.

  1. lostingamma macrumors member

    Apr 4, 2005
    when i try this code in cocoa, i get an error that says too many arguemnts, however, its only one arugment, heres the code:

    the code works fine if instead of using an arguemnt, i completely define the path to the image, but then, i would have to define like 25 images serperatly. and don't worry about what i is set to, thats all taken care of, its just that i keep getting this: "too many arguments to function", when its only 1 argument :(
  2. HexMonkey Administrator


    Staff Member

    Feb 5, 2004
    New Zealand
    The problem is that format strings (those containing format specifiers such as %d) are only supported by a few methods. Luckily there's an easy workaround, using NSString's stringWithFormat, as follows:

    NSImage *tmpImage;
    tmpImage = [[NSImage alloc] init];
    [tmpImage initWithContentsOfFile:[NSString stringWithFormat:@"./Mind", i]];
  3. lostingamma thread starter macrumors member

    Apr 4, 2005

    ohhh, thanks, thats just what i needed, thanks sooooo much :) :)

Share This Page