2 つの UIView があります。呼び出された1つのUIViewには、特定の機能を実行した後に移入さSelectText
れるivarがあります。NSMutableArray
スニペット コードは次のとおりです。
- (void)fillDrawPoints
{
//the codes....
[self.drawnPoints addObject:[NSValue valueWithCGPoint:currPoint]];
}
注:配列drawnPoints
はinitWithFrame
SelectText で初期化されます。また、関数にログを入れて、配列が実際にビュー内に取り込まれているかどうかを常に確認します。
今私がしたいことは、別のビューからこの配列にアクセスすることです。これが私がすることです:
TextView.h
#import "SelectText.h"
@interface TextView : UIView
{
SelectText *txtSel;
}
@property (nonatomic, retain) SelectText *txtSel;
TextView.m
@synthesize txtSel;
- (void)getDrawingPoints:(NSMutableArray *)pointArray
{
self.pointArray = pointArray;
NSLog(@"Array count: %d", [self.pointArray count]);
}
上記のコードからわかるように、後で使用txtSel.drawnPoints
するために内部のデータを に渡そうとしています。textView.pointArray
問題は、txtSel.drawnPoints
別のビューからアクセスしようとすると、常に空が返されることです。ここで何が間違っていますか?
追加:
これが私が着想する方法ですSelectText
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
txtSel = [[SelectText alloc]init];
[self addSubView:txtSel];
//rest of code...
}