2012-06-12 44 views
1

我在我的CustomClass1中有一個屬性: @property(assign)NSString * url;可可:無法從另一個班級獲得房產價值?

- (void)webView:(WebView *)webView decidePolicyForNewWindowAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request newFrameName:(NSString *)frameName decisionListener:(id <WebPolicyDecisionListener>)listener{ 
_url= [[request URL] absoluteString] ; 
NSLog(@"requested url is %@",_url); 
NSInteger index=[_tabView numberOfTabViewItems]; 
NSTabViewItem *newItem=[[NSTabViewItem alloc] init]; 
[_tabView insertTabViewItem:newItem atIndex:index]; 
[newItem setLabel:@"Empty Tab" ]; 
//[_tabView selectPreviousTabViewItem:@"select"]; 
[self initializeWebView:newItem]; 
[[_tabView .tabViewItems objectAtIndex:index] setView:[newVC view]]; 
// NSLog(@"requested url is %@",url); 

}

-(void)awakeFromNib{ 

CustomClass1 *obj=[[CustomClass1 alloc] init]; 
NSLog(@"url is %@",[obj url]); 
[[_newWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:obj.url]]]; 

}

?我怎樣才能_url值在視圖控制器類我awakefromnib方法? NSlog返回null。 我該如何解決這個問題? 請幫我

回答

0

你「url」屬性需要進行分配,並初始化爲東西纔可以返回比「nil」以外的東西。

你可以設置你的「url」屬性的內容在「CustomClass1」對象的「init」的方法,但有一點一招,做這個(see this related StackOverflow question)的。

相關問題