我正在嘗試爲我的應用創建書籤頁。基本上,我想能夠在我的UIViewController中點擊一個按鈕,並將我當前正在查看的網站的網址保存爲UITableViewController中的單元格。問題是我不太確定實現這一點的最佳方式。xcode6中的書籤頁 - Objective-C
我認爲做這將是在我的tableviewcontroller一個可變的數組,我在這裏創建方式:
#import <UIKit/UIKit.h>
@interface FavoriteViewController : UITableViewController
@property (strong, atomic) NSMutableArray *tableItems;
@end
然後我可以用在的viewController按鈕來填充數組。但是,當我嘗試這樣的事情:
- (IBAction)fave:(id)sender {
[FavoriteViewController.tableItems addObject:[NSString self.faveURL]];
}
我收到一個錯誤,在FavoriteViewController上找不到屬性tableItems。不知道這是爲什麼。任何人都有解決方案?
好的。我嘗試了第一個選項,但我的FavoriteViewController似乎不受按鈕按下的影響。我猜是因爲按鈕按下隻影響FavoriteViewController的一個實例,並且該實例在我的應用程序中不是同一個實例。有任何解決這個問題的方法嗎?我需要使用靜態方法嗎? – planner15 2015-02-23 17:23:17
你需要添加更多的代碼,不清楚你在問什麼/ – rishi 2015-02-24 06:09:35
沒關係,我想通了我的問題。 – planner15 2015-02-24 20:05:03