Picker View & Property list

Discussion in 'iPhone/iPad Programming' started by ITCreative, Aug 4, 2011.

  1. macrumors member

    Joined:
    Aug 4, 2011
    #1
    I have Problem with Picker view , I want read the content from Property list but


    I didn't know how can implement this :(


    I try implement but the result = error .:(


    Can help me how implement this in xcode
     
  2. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
  3. thread starter macrumors member

    Joined:
    Aug 4, 2011
    #3
    ^^^^

    thanks a lot :)

    I'm sorry about that. :eek:


    in my code


    Code:
    
    - (void)viewDidLoad {
    
    	NSString *myfile = [[NSBundle mainBundle] pathForResource:@"list" ofType:@"plist"];
    	
    	Names =[[NSArray alloc] initWithContentsOfFile:myfile];
    	
    	
    	
    	
        [super viewDidLoad];
    }
    
    
    
    
    but when I build this line is error :confused:


    Code:
    [COLOR="Red"]	NSString *myfile = [[NSBundle mainBundle] pathForResource:@"list" ofType:@"plist"];[/COLOR]
    
    
     
  4. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    And the error is?...

    The more specific info you can provide us, the easier it'll be for us to help you.
     
  5. thread starter macrumors member

    Joined:
    Aug 4, 2011
    #5
    Ok , thanks a lot :eek:


    In interface :

    Code:
    @interface First_AppViewController : UIViewController <UIPickerViewDelegate,UIPickerViewDataSource>
    
    {
    	NSArray *Names;
    
    	IBOutlet UIPickerView *menuPicker;
    	
    }
    
    @property (nonatomic, retain) UIPickerView *menuPicker;
    
    @end
    
    


    In implementation

    Code:
    
    
    @implementation First_AppViewController
    
    @synthesize menuPicker;
    
    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
    {
    	return 1;
    }
    
    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
    {
    	return Names.count;
    	
    }
    
    - (NSString *)pickerView:(UIPickerView *)pickerView 
    			 titleForRow:(NSInteger)row 
    			forComponent:(NSInteger)component{
    
    	return [Names objectAtIndex:row];
    	
    	
    }
    
    
    
    
    - (void)viewDidLoad {
    
    	
    	NSString *myfile = [[NSBundle mainBundle] 
    						 
    						pathForResource:@"list" ofType:@"plist"];
    	
    	Names =[[NSArray alloc] initWithContentsOfFile:myfile];
    	
        [super viewDidLoad];
    }
    
    
    @end
    
    

    but when build still the error happen :(
     
  6. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    I don't think you're getting the point. What is the error?
     
  7. thread starter macrumors member

    Joined:
    Aug 4, 2011
    #7
    the error happen in this line :confused:


    Code:
    
    NSString *myfile = [[NSBundle mainBundle] 
    						 
    [COLOR="Red"]		pathForResource:@"list" ofType:@"plist"];
    [/COLOR]
    
    I'm sure %100 the Resource folder contain list.plist :confused:
     
  8. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    Perhaps there is a language barrier at work here but if you can't answer a simple question, I can provide no further assistance. Sorry.
     
  9. thread starter macrumors member

    Joined:
    Aug 4, 2011
    #9
    The list.plist contain string but in Arabic becouse my app in arabic
     
  10. jiminaus, Aug 5, 2011
    Last edited: Aug 5, 2011

    macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #10
    You don't answer Dejo's question. What is the error? ما هو الخطأ؟

    If it is an error from the compiler when you build, tell us what that error is. If it is an error that you see in the debugger when you run, tell us what that error is.
     
  11. ITCreative, Aug 6, 2011
    Last edited by a moderator: Aug 6, 2011

    thread starter macrumors member

    Joined:
    Aug 4, 2011
    #11
    the compiler just high lite this line without any comment about what is this error !!!!!!!!!!


    [​IMG]


    [​IMG]


    [​IMG]
     
  12. thread starter macrumors member

    Joined:
    Aug 4, 2011
    #12

    I search about this problem


    then try do just build the build now build success but when press build and debug


    the problem happen :(

    usually why problem happen in debug ?
     
  13. thread starter macrumors member

    Joined:
    Aug 4, 2011
    #13
    thanks a lot for all :eek:

    I solve this problem :cool:
     
  14. Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #14
    What did you do to solve it?

    B
     
  15. ITCreative, Aug 6, 2011
    Last edited: Aug 6, 2011

    thread starter macrumors member

    Joined:
    Aug 4, 2011
    #15
    Just I think there is problem in viewload

    So I put viewLoad in first method of implementation just this.


    but Now I tray solve another problem :

    Now I want If user select item from picker view the second controller display :rolleyes:


    Code:
    
    - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    	
    	NSString *mylist;
    	
    	SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    	
    	switch (row) {
    			
    			
    		case 0: case1:
    			
    			mylist= [[NSBundle mainBundle] pathForResource:@"Menu" ofType:@"plist"];
    			secondViewController.menu =[[NSArray alloc] initWithContentsOfFile:mylist];
    			
    			break;
    }
    
    

    but i did not know how to solve it. I try to solve it now :rolleyes:.

    Is my way true to solve ?
     
  16. thread starter macrumors member

    Joined:
    Aug 4, 2011
    #16
    Code:
    [COLOR="red"]SecondViewController *anotherViewController = [[SecondViewController alloc] [/COLOR]
    														   
    														   initWithNibName:@"SecondViewController" bundle:nil];
    			
    			[self.navigationController [COLOR="Red"]pushViewController:anotherViewController animated:YES];[/COLOR]
    			
    			[anotherViewController release];
    
    
    

    in line 1: the error is : expected expression before 'SecondViewController'


    in other line : the error is : anotherViewController undeclared


    I think if resolve the first error the second will be resolve

    but why the error 1 happen :confused:
     

Share This Page