0

I am attempting to copy an array in my ViewController to a Data storage class. None of the array copy methods I have found are actually working. Currently I have..

   //XML parser is returning an array of parsed objects
    NSMutableArray *randomtesting = [parser listArray];
    customerList.list =[[NSMutableArray alloc] initWithArray:randomtesting copyItems:YES];

    NSLog(@"First node randomtesting: %@",[randomtesting objectAtIndex:0]);
    NSLog(@"First node customerList: %@",[customerList.list objectAtIndex:0]);

The first NSLog prints out the value correctly. The second prints out a Null. I have also tried

customerList.list =randomtesting;

and

customerList.list = [paser listArray];

The .h of my Viewcontroller for this class is as follows

#import <UIKit/UIKit.h>


@class CustomerListData;

@interface ViewController : UIViewController <UIAlertViewDelegate, UITextFieldDelegate>{

    CustomerListData *customerList;

}


@property (nonatomic, retain) CustomerListData *customerList;

The class's .h of the array variable is

 #import <Foundation/Foundation.h>

 @interface CustomerListData : NSObject{

   NSMutableArray *list;
 }


 @property (nonatomic, retain) NSMutableArray *list;

 @end

the .m is just

@synthesize list;

I believe all of my variable declarations are correct, I'm just not copying it correctly. But I none of the methods seem to work.

Thanks.

1 Answer 1

2

Are you initializing your ViewController's customerList property anywhere i.e. doing something like this:

self.customerList = [[[CustomerListData alloc] init] autorelease];

If not, then this property will be nil and all your attempts at accessing the customerList.list child property will fail silently because you are sending an Objective-C message to nil.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.