我试图通过调用循环数组的不同类中的方法并附加一个字符串来显示数组的内容。然而,当我转向该视图时,它没有显示任何内容。我添加了断点来检查数组中是否有任何内容,并且数据肯定存储在内部。 有没有理由发生这种情况?
我想要显示所有数组内容的Portrait类
portrait.h
#import <UIKit/UIKit.h>
#import "Brain.h"
@interface PortraitTape : UIViewController
@property (weak, nonatomic) IBOutlet UITextView *equationView;
@property (nonatomic,strong) Brain *brain;
@end
portrait.m
#import "PortraitTape.h"
@interface PortraitTape ()
@end
@implementation PortraitTape
@synthesize brain = _brain;
@synthesize equationView;
- (Brain *) brain{
if (!_brain)_brain =[[Brain alloc]init];
return _brain;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSString *tape;
tape = [self.brain gettape];
equationView.text = tape;
}
正在插入数组和数据的Brain.m类方法。此方法在肖像类中调用。
-(NSString*) gettape {
NSMutableString *tape = [[NSMutableString alloc]init];
for(NSString * myStr in _equation) {
//tape = myStr;
[tape appendFormat:@"\n%@",myStr];
}
return tape;
}