• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: objectForKey crashes for string formats
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: objectForKey crashes for string formats


  • Subject: Re: objectForKey crashes for string formats
  • From: Lorenzo <email@hidden>
  • Date: Thu, 22 May 2003 10:42:11 +0200

Hi,
thank you for replying. I explain better.
I have a NSDictionary (plist) file called "Localizable.strings" which
contains many objects (sentences). I have this file in each of the language
folders (e.g. English.lproj, French.lproj, ...).
I load the "Localizable.strings" at the launch time from the proper folder
regarding the current system language.
For any object of the dictionary I search for the key (it's always in
english) and I get the binded translated string.

So If I have to show a string to the user I do:

[self GLS:@"Registration:"]

and the routine I call is:

//////////////////////////////////////////////
- (NSString*)GLS:(NSString*)originalString
{
NSString *foundString;

if(!theString) return @"";

foundString = [gLanguageStringsDict objectForKey:originalString];

if([foundString isEqualToString:@""]) return originalString;
if(foundString == nil) return originalString;

return foundString;
}
//////////////////////////////////////////////

So, if I earlier loaded the file "Localizable.strings"
from the folder "French.lproj",
I search for "Registration:" and I get "Enregistrement:".

But I cannot yet search for strings containing \r and %@
So I should workaround this problem.
I am going to take a look at the link you gave me. Thank you.

Best Regards
--
Lorenzo
email: email@hidden

> From: Chuck Soper <email@hidden>
> Date: Thu, 22 May 2003 01:16:24 -0700
> To: Lorenzo <email@hidden>, <email@hidden>
> Subject: Re: objectForKey crashes for string formats
>
> I believe that the @"string" directive creates an instance of
> NSConstantString.
> I don't know why \r and %@ is causing a problem.
>
> Shouldn't you use strings files for localization? Or do you have a
> special circumstance?
> http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/ProgrammingT
> opics/Internationalization/Concepts/StringsFiles.html
>
> Chuck
>
>
> At 9:35 AM +0200 5/22/03, Lorenzo wrote:
>> Hi,
>> I use a NSDictionary to localize my software in different languages.
>> I have just discovered that if I try to get from a NSDictionary
>>
>> theKey = @"Cannot save the file:\r%@";
>> foundString = [gLanguageStringsDict objectForKey:theKey];
>> my application crashes if the key is in the dictionary.
>>
>>
>> And if the key is only:
>> theKey = @"Cannot save the file:\r";
>> objectForKey returns nil even if the key is in the dictionary.
>>
>>
>> And if the key is:
>> theKey = @"Cannot save the file:";
>> objectForKey finds the key and returns the string properly.
>>
>> So, cannot I really use those characters \r and %@ ?
>> Is it a NSDictionary's bug?
>> Is it my fault?
>>
>>
>> Best Regards
>> --
>> Lorenzo
>> email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: objectForKey crashes for string formats (From: Chuck Soper <email@hidden>)

  • Prev by Date: What causes this error : MIG: server died : CGSExtractEventRecordsFromMessage
  • Next by Date: Re: using a parser generator with a cococa app
  • Previous by thread: Re: objectForKey crashes for string formats
  • Next by thread: Re: objectForKey crashes for string formats
  • Index(es):
    • Date
    • Thread