Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ITCreative

macrumors member
Original poster
Aug 4, 2011
46
0
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
 
^^^^

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]
 
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 :(
 
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:
 
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.
 
the error happen in this line :confused:
Code:
NSString *myfile = [[NSBundle mainBundle] 						 
[COLOR="Red"]pathForResource:@"list" ofType:@"plist"];[/COLOR]

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.
 
Last edited:
the compiler just high lite this line without any comment about what is this error !!!!!!!!!!


060903_b105.jpg



060904_k105.jpg



060904_m105.jpg
 
Last edited by a moderator:

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 ?
 
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 ?
 
Last edited:
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:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.