-1

私は持っています:

NSMutableArray *arr1 = [NSMutableArray arrayWithObjects:[customArray objectAtIndex:0], [customArray objectAtIndex:1], nil];  

プッシュするたびにarr1配列を収集するためにotherArrayが必要です。したがって、otherArrayにはいくつかのarr1配列が含まれます。どうすればいいですか?

4

2 に答える 2

0
NSMutableArray *otherArray=[NSMutableArray array];

各プッシュの後:

[otherArray addObject:[NSMutableArray arrayWithArray:arr1]];
于 2012-11-15T13:43:54.157 に答える
0

あなたの質問は明確ではありませんか?次回のために明確にしてください。

次の例を試してください

これは私の FirstViewController.h です

#import <UIKit/UIKit.h>
#import "SecondViewController.h"

@interface FirstViewController : UIViewController
{

    NSArray *first_Array;
}
-(IBAction)nextViewController:(id)sender;
@end

This is my FirstViewController.m .Call nextViewcontroller method with a button

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
first_Array=[[NSArray alloc] initWithObjects:@"one",@"two",@"three",@"four",@"five",@"six",@"seven",@"eight",@"nine",@"ten", nil];



}
-(IBAction)nextViewController:(id)sender
{
    SecondViewController *obj=[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    [self.navigationController pushViewController:obj animated:YES];
    [obj receivingArrayFromFirstViewController:first_Array];

}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end





This is my SecondViewController.h

#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController
{

}
-(void)receivingArrayFromFirstViewController:(NSArray*)array;

@end


This is my SecondViewController.m

#import "SecondViewController.h"

@interface SecondViewController ()

@end

@implementation SecondViewController

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

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}
-(void)receivingArrayFromFirstViewController:(NSArray*)array
{
    NSMutableArray *arr=[NSMutableArray arrayWithArray:array];
    NSLog(@"The received array %@",arr);
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
于 2012-11-15T14:16:33.570 に答える