从NSMutableArray检索自定义类对象属性

时间:2014-03-16 23:46:57

标签: objective-c nsmutablearray

 //controller header file.
@interface MasterVaultDataViewController : UITableViewController

 @property(nonatomic,strong) NSMutableArray *sectionTittle;

 @end

//controller m class
#import "MasterVaultDataViewController.h"
#import "PasswordKeeper.h"

@interface MasterVaultDataViewController (){
    PasswordKeeper *cathegory1,*cathegory2,*cathegory3;
    UIImage *image2;
}


@end

@implementation MasterVaultDataViewController


-(NSMutableArray *) sectionTittle{

    if(!_sectionTittle){
        _sectionTittle = [[NSMutableArray alloc] init];
    }
    return _sectionTittle;
}

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}


- (void)viewDidLoad
{
    [super viewDidLoad];

     cathegory1 = [[PasswordKeeper alloc]init];
    [cathegory1 setTitle:@"Concepcion"];
    [cathegory1 setSubtitle:@"Parte Del Sur"];

    cathegory2 = [[PasswordKeeper alloc]init];
    [cathegory2 setTitle:@"Santiago"];
    [cathegory2 setSubtitle:@"Norte"];

    cathegory3 = [[PasswordKeeper alloc]init];
    [cathegory3 setTitle:@"Bariloche"];
    [cathegory3 setSubtitle:@"Argentine"];
    [_sectionTittle addObject:[cathegory1 class]];


   //Custom Class h file

@interface PasswordKeeper : NSObject
@property(nonatomic,strong) NSString *title;
@property(nonatomic,strong) NSString *subtitle;
@end

   //custom class m file

     #import "PasswordKeeper.h"

     @implementation PasswordKeeper

     @end

我已经从我的PasswordKeeper类创建了3个对象并将它们添加到了一个 我的控制器中的NSMutableArray属性。我首先设置了每个对象的属性。 现在我想检索对象的属性。这是一些代码。

0 个答案:

没有答案