PDA

View Full Version : Picker View & Property list




ITCreative
Aug 4, 2011, 06:28 PM
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



jnoxx
Aug 5, 2011, 02:21 AM
As most people would react, so I'll be the one to break it to you:
Check these ->
Getting Answers (http://www.mikeash.com/getting_answers.html)
And What have you tried? (http://mattgemmell.com/2008/12/08/what-have-you-tried)

Gz, Noxx

ITCreative
Aug 5, 2011, 02:39 PM
^^^^

thanks a lot :)

I'm sorry about that. :o


in my 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:



NSString *myfile = [[NSBundle mainBundle] pathForResource:@"list" ofType:@"plist"];

dejo
Aug 5, 2011, 06:39 PM
but when I build this line is error :confused:

And the error is?...

The more specific info you can provide us, the easier it'll be for us to help you.

ITCreative
Aug 5, 2011, 07:53 PM
Ok , thanks a lot :o


In interface :


@interface First_AppViewController : UIViewController <UIPickerViewDelegate,UIPickerViewDataSource>

{
NSArray *Names;

IBOutlet UIPickerView *menuPicker;

}

@property (nonatomic, retain) UIPickerView *menuPicker;

@end





In implementation




@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 :(

dejo
Aug 5, 2011, 08:17 PM
...but when build still the error happen :(

I don't think you're getting the point. What is the error?

ITCreative
Aug 5, 2011, 08:30 PM
the error happen in this line :confused:




NSString *myfile = [[NSBundle mainBundle]

pathForResource:@"list" ofType:@"plist"];



I'm sure %100 the Resource folder contain list.plist :confused:

dejo
Aug 5, 2011, 09:51 PM
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.

ITCreative
Aug 5, 2011, 10:54 PM
The list.plist contain string but in Arabic becouse my app in arabic

jiminaus
Aug 5, 2011, 11:28 PM
the error happen in this line :confused:

NSString *myfile = [[NSBundle mainBundle]
pathForResource:@"list" ofType:@"plist"];



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.

ITCreative
Aug 6, 2011, 02:07 PM
the compiler just high lite this line without any comment about what is this error !!!!!!!!!!


http://up.alhilalclub.com/uploads/public/2011/08/060903_b105.jpg


http://up.alhilalclub.com/uploads/public/2011/08/060904_k105.jpg


http://up.alhilalclub.com/uploads/public/2011/08/060904_m105.jpg

ITCreative
Aug 6, 2011, 04:47 PM
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 ?

ITCreative
Aug 6, 2011, 05:20 PM
thanks a lot for all :o

I solve this problem :cool:

balamw
Aug 6, 2011, 05:53 PM
thanks a lot for all :o

I solve this problem :cool:

What did you do to solve it?

B

ITCreative
Aug 6, 2011, 07:41 PM
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:



- (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 ?

ITCreative
Aug 6, 2011, 11:20 PM
SecondViewController *anotherViewController = [[SecondViewController alloc]

initWithNibName:@"SecondViewController" bundle:nil];

[self.navigationController pushViewController:anotherViewController animated:YES];

[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: