Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone sdk how to receive string value?
    primarykey
    data
    text
    <p>In my application, i need to provide three languages support. My default language will be English. Once the user selects other language in setting controller the entire application should change into that particular language. For this i decided to have a plist file with all the three languages and their data in it.Now my default language is English that is fine. Now i changed the language using plist in LanguageController and pushed to home controller. The selected language(French) string was not received in my home controller. Here is my code,</p> <pre><code>//LanguageController.h NSMutableDictionary *allDictElements; NSString *selectedLanguage1; NSArray *dummy; @property(nonatomic,retain) NSMutableDictionary *allDictElements; @property(nonatomic,retain) NSString *selectedLanguage1; @property(nonatomic,retain) NSArray *dummy; //LanguageController.m @synthesize allDictElements,selectedLanguage1,dummy; - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *path= [[NSBundle mainBundle] pathForResource:@"Language" ofType:@"plist"]; allDictElements = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; NSLog(@"%@allDictElements",allDictElements); LeeValleyHomeViewController *homeController = [[LeeValleyHomeViewController alloc] initWithNibName:@"LeeValleyHomeViewController" bundle:[NSBundle mainBundle]]; if (indexPath.row ==0) { //bookshelf button NSMutableDictionary *english=[[NSMutableDictionary alloc]init]; english=[allDictElements objectForKey:@"English Language"]; dummy=[english objectForKey:@"English"]; selectedLanguage1=[dummy objectAtIndex:0]; NSLog(@"english bookshelf button:%@",selectedLanguage1); homeController.selectedLanguage = selectedLanguage1; NSLog(@"sel lang:%@",homeController.selectedLanguage); } else if (indexPath.row ==1) { //bookshelf button NSMutableDictionary *french=[[NSMutableDictionary alloc]init]; french=[allDictElements objectForKey:@"French Language"]; dummy=[french objectForKey:@"French"]; selectedLanguage1=[dummy objectAtIndex:0]; NSLog(@"french bookshelf button:%@",selectedLanguage1); homeController.selectedLanguage = selectedLanguage1; NSLog(@"sel lang:%@",homeController.selectedLanguage); } else { NSMutableDictionary *spanish=[[NSMutableDictionary alloc]init]; spanish=[allDictElements objectForKey:@"Spanish Language"]; dummy=[spanish objectForKey:@"Spanish"]; selectedLanguage1=[dummy objectAtIndex:0]; NSLog(@"spanish bookshelf button:%@",selectedLanguage1); homeController.selectedLanguage = selectedLanguage1; NSLog(@"sel lang:%@",homeController.selectedLanguage); } [self.navigationController pushViewController:homeController animated:YES]; } </code></pre> <p>Here in this controller am receiving the selected language string finely.</p> <pre><code>//LeeValleyHomeViewController.h NSString *selectedLanguage; @property (nonatomic,retain) NSString *selectedLanguage; //LeeValleyHomeViewController.m @synthesize selectedLanguage; - (void)viewDidLoad { LanguageViewController lvc = [LanguageViewController alloc]init]; bookshelfbtn.titleLabel.text = lvc.selectedLanguage1; NSLog(@"button title:%@",bookshelfbtn.titleLabel.text); //bookshelfbtn.titleLabel.text = selectedLanguage; } </code></pre> <p>Here in this controller am not receiving that string value. What's wrong with my code? or how can i do this? Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload