私は基本的に、私がいるメソッドから既知の文字列を送信したいと思います。
NSString *websiteString;
if(a==0)
websiteString = [[[NSString alloc] initWithString:@"www.google.com"] autorelease];
else
websiteString = [[[NSString alloc] initWithString:@"www.yahoo.com"] autorelease];
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
aButton.frame = rct;
// I get thrown in this next line: how do I initialize the Value for key?
[aButton setValue:websiteString forKey:@"website"];
[aButton addTarget:self action:@selector(clickedInsidePage:) forControlEvents:UIControlEventTouchUpInside];
送信された文字列をUIWebviewにロードできるコールバック関数へ...
-(void)clickedInsidePage:(id)sender {
NSString *websiteString = [[[NSString alloc] initWithString:[((UIControl *) sender) valueForKey:@"website"]] autorelease];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:[NSURL URLWithString:websiteString]];
NSLog(@"visiting: %@",websiteString);
.
.
.
}
しかし、キー/値が実際に設定または初期化されていないため、エラーがスローされます。