Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Applescript with cocoa Renmusxd Mac Programming 0 Nov 16, 2010 11:06 PM
Finally, an iPod accessory even Greenpeace canít bash (too m... MacBytes MacBytes.com News Discussion 2 Jan 28, 2008 02:43 AM
My macbook's temp... (too hot) charlyelamo Buying Tips and Advice 16 Sep 22, 2006 12:37 PM
cheap tech service at apple (too bad apple care wasn't *that* cheap) aflacco Mac Pro 4 Sep 4, 2006 10:16 AM
macbook + backpack (too small) jbusc Mac Basics and Help 5 Aug 7, 2006 02:09 PM


All times are GMT -5. The time now is 03:57 AM.

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

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