NSBundle Help


i finished super cool experience point calculator our rolemaster rpg. (yep, geek @ heart!). did release build , images files not there. chown33 explained me need nsbundle , read documentation did not understand completely. scoured web , tutorial wise xcode 3 or iphones.

here how access images right now.
code:
-(void)setroundimages{      nsimage *roneoff = [[nsimage alloc] initwithcontentsoffile:@"/volumes/media_projects/programing/objective_c/xp calc2/images/roneoff2.png"];      [roundonelight setimage:roneoff];      [roneoff release];  
i have images in image folder within project. if understand nsbundle correctly use gather images , bring them program use. bring in image folder or each image it's self?

if has links tutorials explain better or sample files, thankful. there many methods in nsbundle class , getting lost.

last step before can final working build! can share it!

-lars
 

nsbundle class managing bundles of files, applications , on. [nsbundle mainbundle] represents running application's bundle.

need drag of images source list of xcode project if they're not there.

once they're there, xcode copy images application bundle on build.

once there, can use nsimage method them out - code:
code:
  -(void)setroundimages{      nsimage *roneoff = [[nsimage alloc] initwithcontentsoffile:@"/volumes/media_projects/programing/objective_c/xp calc2/images/roneoff2.png"];      [roundonelight setimage:roneoff];      [roneoff release];  
... becomes ...

code:
  -(void)setroundimages{      nsimage *roneoff = [nsimage imagenamed:@"roneoff2.png"];      [roundonelight setimage:roneoff];  
fwiw, [nsimage imagenamed:] shortcut for:

code:
      nsstring *path = [[nsbundle mainbundle] pathforresource:@"roneoff2.png" oftype:@""];      nsimage *image = [[nsimage alloc] initwithpath:path];      return [image autorelease];  
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

Has to be the funniest headline ive ever seen

Man Brings Goat to Apple Store and has Pizza Delivered

Elusive Ninja: The Shadowy Thief - Can you survive the fast-paced ninja chaos?