Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 4, 2005, 06:19 PM   #1
lostingamma
macrumors member
 
Join Date: Apr 2005
Cocoa (too many arguments)

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

Quote:
NSImage *tmpImage;
tmpImage = [[NSImage alloc] init];
[tmpImage initWithContentsOfFile:@"./Mind Reader.app/Contents/Resources/%dcopy.tif", i];
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
lostingamma is offline   0 Reply With Quote
Old Apr 4, 2005, 08:40 PM   #2
HexMonkey
Administrator
 
HexMonkey's Avatar
 
Join Date: Feb 2004
Location: 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:

Code:
NSImage *tmpImage;
tmpImage = [[NSImage alloc] init];
[tmpImage initWithContentsOfFile:[NSString stringWithFormat:@"./Mind Reader.app/Contents/Resources/%dcopy.tif", i]];
HexMonkey is offline   0 Reply With Quote
Old Apr 4, 2005, 09:22 PM   #3
lostingamma
Thread Starter
macrumors member
 
Join Date: Apr 2005
ohhh

ohhh, thanks, thats just what i needed, thanks sooooo much
lostingamma is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
NSRegularExpression to capture C function arguments? ArtOfWarfare Mac Programming 13 Jun 17, 2013 11:17 PM
Accepting arguments of multiple types? moonman239 iPhone/iPad Programming 8 Jun 5, 2013 01:35 AM
Resolved: variable arguments help (Cocoa format string) ArtOfWarfare Mac Programming 1 May 1, 2013 02:22 AM
Calling applescript from objective c code with arguments Jitin Jindal Mac Programming 2 Mar 4, 2013 11:03 AM

Forum Jump

All times are GMT -5. The time now is 09:37 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC