我目前在方法中构建了一个NSMutableArray
in Class AmViewDidLoad
。
- (void)viewDidLoad
{
[super viewDidLoad];
//Question Array Setup and Alloc
stratToolsDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:countButton,@"count",camerButton,@"camera",videoButton,@"video",textButton,@"text",probeButton,@"probe", nil];
stratTools = [[NSMutableArray alloc] initWithObjects:@"Tools",stratToolsDict, nil];
stratObjectsDict = [[NSMutableDictionary alloc]initWithObjectsAndKeys:stratTools,@"Strat1",stratTools,@"Strat2",stratTools,@"Strat3",stratTools,@"Strat4", nil];
stratObjects = [[NSMutableArray alloc]initWithObjects:@"Strategies:",stratObjectsDict,nil];
QuestionDict = [[NSMutableDictionary alloc]initWithObjectsAndKeys:stratObjects,@"Question 1?",stratObjects,@"Question 2?",stratObjects,@"Question 3?",stratObjects,@"Question 4?",stratObjects,@"Question 5?", nil];
//add strategys to questions
QuestionsList = [[NSMutableArray alloc]init];
for (int i = 0; i < 1; i++) {
[QuestionsList addObject:QuestionDict];
}
NSLog(@"Object: %@",QuestionsList);
在此方法结束时,您将看到 QuestionsList 正在初始化,现在我需要将其发送Array
到Class B。
所以我放置它setters
并getters
使用@property
and@Synthesize
方法。
阿班
@property (retain, nonatomic) NSMutableDictionary *stratToolsDict;
@property (retain, nonatomic) NSMutableArray *stratTools;
@property (retain, nonatomic) NSMutableArray *stratObjects;
@property (retain, nonatomic) NSMutableDictionary *QuestionDict;
@property (retain, nonatomic) NSMutableArray *QuestionsList;
上午班
@synthesize QuestionDict;
@synthesize stratToolsDict;
@synthesize stratObjects;
@synthesize stratTools;
@synthesize QuestionsList;
我使用属性方法是因为我要从B 类调用这个变量并希望能够将它分配给另一个NSMutableArray
.
然后,我将 A 类的 and 添加到Bh@property
类,并在 @interface中声明。@class
NSMutableArray
#import "Class A.h"
@class Class A;
@interface Class B : UITableViewController<UITableViewDataSource, UITableViewDelegate>{
NSMutableArray *QuestionList;
Class A *arrayQuestions;
}
@property Class A *arrayQuestions;
然后我NSMutableArray
从 Bm 班的 A 班打电话
-(id)initWithStyle:(UITableViewStyle)style
{
if ([super initWithStyle:style] != nil) {
//Make array
arrayQuestions = [[Class A alloc]init];
QuestionList = arrayQuestions.QuestionsList;
在此之后,我记录NSMutableArray
以查看值并检查它们是否存在并返回NIL
。
//Log test
NSLog(@"QuestionList init method: %@",QuestionList);
关于B类的信息-
B 类是A 类的UIPopOverController
,B类有一个视图,它包含一个我必须填充A 类的结果的视图。UITableView
NSMutableArray
为什么NsMutableArray
回来了NIL
?最终也需要一些帮助来解决这个问题,这似乎真的让我很困惑。非常感谢您的帮助!