I’m developing an app to create as many notes as you want, something like post-it’s. I’m adding views and putting the into a viewArray
- (IBAction)add:(id)sender {
NoteViewController *noteController = [[NoteViewController alloc]initWithNibName:@"NoteViewController" bundle:nil];
[self.view addSubview:noteController.view];
UIView *myAddedView = (UIView *)[noteController view];
[viewArray insertObject:myAddedView atIndex:0];
noteController.myTextView.tag = viewArray.count;}
As you can see, I’m adding tags to textviews in the noteController even after the cast to addviews so I can get the textview text by the time I want to export the content from all textviews created.
- (IBAction)export:(id)sender{
NSData *myData;
NSInteger *cont = (NSInteger *)viewArray.count;
for (UIView *subviewa in [self.view subviews])
{
if(cont>0)
if (subviewa.tag == 0)
myData = (NSData *)[subviewa viewWithTag:1];
NSLog(@"%@", myData);
}
cont--;
}
When I clic Export I get
<UITextView: 0x684a130; frame = (6 0; 84 92); text = 'my text'; clipsToBounds = YES;
autoresize = RM+BM; tag = 1; layer = <CALayer: 0x684a310>; contentOffset: {0, 0}>
As far as I know, this is a nsdata. I’ve tried JSON, casting… and when I try to access text property the app crashes. I need help to access textviews texts from all objects in viewarray. Thank you in advance for your help.
Any view has it’s subviews array. So when you add textview to view, and there is no other objects in this view, you car refer to textview like this:
And get text property like this:
Code of
export:method to return all views from array and display their textviews text: