Firstly, the contents of a file may be read and stored in an NSData object through the use of the contentsAtPath method: NSFileManager *filemgr; NSData *databuffer; filemgr = [NSFileManager defaultManager]; databuffer = [filemgr contentsAtPath: @"/tmp/myfile. txt" ];
A static, plain-text Unicode string object that bridges to String ; use NSString when you need reference semantics or other Foundation-specific behavior.
I'm creating a Mac app and I want to localize my Labels. I thought a .strings
file would be a better choice. But I have trouble reading .strings
file in Objective-C. I'm looking for a simpler method.
This is my .string
file content:
"LABEL_001" = "Start MyApp";
"LABEL_002" = "Stop MyApp";
"LABEL_003" = "My AppFolder";
...
I have already looked at http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/LoadingResources/Strings/Strings.html.
This is my code:
NSBundle *bundle = [NSBundle mainBundle];
NSString *strFilePath = [[NSBundle mainBundle] pathForResource:@"Labels" ofType:@"strings"];
NSString *tt =NSLocalizedStringFromTableInBundle(@"LABEL_001",strFilePath,bundle, nil);
NSLog(@"STRING ::: %@",tt);
But the string tt gives "LABEL_001"
, I want "Start MyApp"
What am I doing wrong?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With