0

ここでは、firstviewcontroller の nsmutablearray に値を追加しています。UIButton をクリックすると、この配列を別のビュー コントローラーに渡します。

AppointmentClass *appObj = [[AppointmentClass alloc]init];
appObj.subject = [key objectForKey:@"Subject"];
appObj.location = [key objectForKey:@"Location"];
appObj.scheduledStart = [key objectForKey:@"ScheduledStart"];
appObj.scheduledEnd = [key objectForKey:@"ScheduledEnd"];
[firstNameArray addObject:appObj];            
[appObj release];
appObj=nil;

firstnamearray の値をアポイントメントデータアレイに渡すとき。

secondviewcontroller *appointmentViewObject = [[secondviewcontroller alloc]initWithNibName:@"secondviewcontroller" bundle:nil];
[appointmentViewObject setAppointmentDataArray:firstNameArray];

上記から、ヌル値を返す予定データ配列。

[self presentModalViewController:appointmentViewObject animated:YES];
[appointmentViewObject release];
4

4 に答える 4

0

1 つのことを試すことができますsecondviewcontroller.m: 次のメソッドを追加します。

-(id) initwithnibName:(NSString*)_nib withArray:(NSMutableArray*)_array{

  self = [super initWithNibName:_nib bundle:nil];

if (self) {
    self.array =_array;
}
return self;

}

に追加-(id) initwithnibName:(NSString*)_nib withArray:(NSMutableArray*)_array;secondviewcontroller.hます。

今すぐ交換secondviewcontroller *appointmentViewObject = [[secondviewcontroller alloc]initWithNibName:@"secondviewcontroller" bundle:nil]; [appointmentViewObject setAppointmentDataArray:firstNameArray];

secondviewcontroller *appointmentViewObject = [[secondviewcontroller alloc]initwithnibName:@"secondviewcontroller" withArray:firstNameArray];

お役に立てれば。

于 2013-05-15T10:15:12.437 に答える
0

ステートメントを変更してみてください:

  [appointmentViewObject setAppointmentDataArray:firstNameArray];

これとともに:

  [appointmentViewObject setAppointmentDataArray:[NSArray arrayWithArray:firstNameArray]];
于 2013-05-15T10:18:59.713 に答える
0

これを使って:

secondviewcontroller.h ファイル

 NSMutableArray* AppointmentDataArray;

 @property(nonatomic,retain) NSMutableArray* AppointmentDataArray;
 -(void)setMyArray:(NSMutableArray *)arr;

secondviewcontroller.m ファイル

 @synthesize AppointmentDataArray;

 - (id)initWithNibName:(NSString *)nibNameOrNil 
            bundle:(NSBundle *)nibBundleOrNil
 {
      if ((self = [super initWithNibName:nibNameOrNil 
                            bundle:nibBundleOrNil])) {
         // Custom initialization.
           AppointmentDataArray = [[NSMutableArray alloc] init];
       }
    return self;
  }

   -(void)setMyArray:(NSMutableArray *)arr{
          AppointmentDataArray=arr;
    }

///////押すと

   secondviewcontroller *appointmentViewObject = [[secondviewcontroller alloc]initWithNibName:@"secondviewcontroller" bundle:nil];
   [appointmentViewObject setMyArray:firstNameArray];
   [self presentModalViewController:appointmentViewObject animated:YES];
于 2013-05-15T10:23:10.160 に答える