Thursday, 15 July 2010

iphone - Saving an array object as a string within a picker view? -


So I'm working with a pickerview and string for one of the many things I need to have a array stored in the code for the pickerview code code looks like this.

  - (zero) picker view: (UIPRView *) PickWarze did select: Compound in line (NSINTEGER) component {switch (line) {Case 0: image .image = image1; Email = email array [1]; break; Case 1: image.image = image2; Email = EmailArray [3]; break; Case 2: image.image = image3; Email = email order [5]; break; } NSLog (@ "% @", email)}   

This code works fine as far as I can tell. The NSLog gives the correct email every time here, the user then presses a button that uses the "email" string. Here is the first part of that code.

  - (IBAction) sendFeedback: (ID) sender {NSLog (@ "% @", email); }   

does not return the correct email here only; it just freeze the program and gives me a threading error that is NSLog Indicates that I am not passing the array in the string correctly?

If I change this code then it works fine.

  switch (line) {case 0: image.image = image1; Email = @ "testEmail@gmail.com"; break;   

After this, both the NSLogs test will display the email

Please help me understand this problem if you need more information. Just ask

Edit

Here is the start of my ViewController.h file.

  @interface ViewController: UIViewController & lt; UIPickerViewDataSource, UIPickerViewDelegate, UIImagePickerControllerDelegate & gt; {NSMutableArray * EmailArray; }   

See here where the email has been declared in ViewController.h.

  @implementation ViewController NSString * email;   

The error I see like this.

  thread 1: EXC_BAD_ACCESS (code = 2, address = 0x14)    

You must not declare as email as a code; a NSString should be declared as a property with a copy modifier

  @property (copy, nonatomic) NSString * Email;    

No comments:

Post a Comment