PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 28, 2022

[FIXED] How can I get relative path?

 April 28, 2022     objective-c, path, relative-path, warnings     No comments   

Issue

I'm programming on objective-c. I have 3 folders with 3 languages such as en, ru, fr with pictures 1.png, 2.png, 3.png. How can I get relative path for my pictures? How should I add this files in my project? I have some warnings. Its because I have the same name of sources.

Warning: Multiple build commands for output file /Users/Kate/Documents/XCode_progs/MyProject/build/Debug-iphonesimulator/MyProject/1.png
Warning: Multiple build commands for output file /Users/Kate/Documents/XCode_progs/MyProject/build/Debug-iphonesimulator/MyProject/2.png
Warning: Multiple build commands for output file /Users/Kate/Documents/XCode_progs/MyProject/build/Debug-iphonesimulator/MyProject/3.png

My code doesn't work:

CCSprite *button = [CCSprite spriteWithFile:[NSString stringWithFormat:@"%@/1.png", lang]];

Solution

Add your images to your project, that you can call:

[[NSBundle mainBundle] pathForResource:@"1" ofType:@"png"];

If you add localization to this resource (png image) (in XCode 4 choose image file and in Utility panel (on right hand) you can add different localizations), then in runtime iOS choose properly localized file automatically.



Answered By - 5hrp
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing