質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

1回答

4570閲覧

Swift cannot override with a stored property 、extra argument in call

pice

総合スコア409

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2016/12/02 19:27

SwiftによるシンプルなRSSリーダーの作り方 - WebFood
を参考に、RSSリーダーを作成しようとしていますが、質問に記載した「cannot override with a stored property」、「extra argument in call」のエラーが出て、buildができません。
stackoverflow等みてみたのですが、解決方法がわかりませんので、ご教示ください。

swift

1import UIKit 2import Alamofire 3import SwiftyJSON 4 5class TableViewController: UITableViewController { 6 7 var fetchFrom: String? 8 var parent: UIViewController? // Cannot override with a stored property 'parent' 9 10 override func viewDidLoad() { 11 super.viewDidLoad() 12 Alamofire.request(.GET, fetchFrom!).responseJSON { response in // Extra argument in call 13 if let values = response.result.value { 14 JSON(values)["responseData"]["feed"]["entries"].forEach { i,value in 15 print(value["title"].string!) 16 print(value["link"].string!) 17 } 18 } 19 } 20 21 // Uncomment the following line to preserve selection between presentations 22 // self.clearsSelectionOnViewWillAppear = false 23 24 // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 25 // self.navigationItem.rightBarButtonItem = self.editButtonItem() 26 } 27 28 override func didReceiveMemoryWarning() { 29 super.didReceiveMemoryWarning() 30 // Dispose of any resources that can be recreated. 31 } 32 33 // MARK: - Table view data source 34 35 override func numberOfSections(in tableView: UITableView) -> Int { 36 // #warning Incomplete implementation, return the number of sections 37 return 0 38 } 39 40 override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 41 // #warning Incomplete implementation, return the number of rows 42 return 0 43 } 44 45 /* 46 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 47 let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) 48 49 // Configure the cell... 50 51 return cell 52 } 53 */ 54 55 /* 56 // Override to support conditional editing of the table view. 57 override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { 58 // Return false if you do not want the specified item to be editable. 59 return true 60 } 61 */ 62 63 /* 64 // Override to support editing the table view. 65 override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { 66 if editingStyle == .delete { 67 // Delete the row from the data source 68 tableView.deleteRows(at: [indexPath], with: .fade) 69 } else if editingStyle == .insert { 70 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 71 } 72 } 73 */ 74 75 /* 76 // Override to support rearranging the table view. 77 override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) { 78 79 } 80 */ 81 82 /* 83 // Override to support conditional rearranging of the table view. 84 override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { 85 // Return false if you do not want the item to be re-orderable. 86 return true 87 } 88 */ 89 90 /* 91 // MARK: - Navigation 92 93 // In a storyboard-based application, you will often want to do a little preparation before navigation 94 override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 95 // Get the new view controller using segue.destinationViewController. 96 // Pass the selected object to the new view controller. 97 } 98 */ 99 100}
import UIKit import PageMenu class ViewController: UIViewController { var pageMenu : CAPSPageMenu? override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. var controllers : [UIViewController] = [] var feeds: [Dictionary<String, String>] = [ [ "link": "https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://menthas.com/top/rss", "title": "top" ], [ "link": "https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://menthas.com/ruby/rss", "title": "ruby" ], [ "link": "https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://menthas.com/ios/rss", "title": "ios" ], [ "link": "https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://menthas.com/infrastructure/rss", "title": "infrastructure" ], ] for feed in feeds { let feedController = TableViewController(nibName: "TableViewController", bundle: nil) feedController.parent = self feedController.fetchFrom = feed["link"]! feedController.title = feed["title"] controllers.append(feedController) } let params: [CAPSPageMenuOption] = [ .scrollMenuBackgroundColor(UIColor.black), .viewBackgroundColor(UIColor.white), .selectionIndicatorColor(UIColor.orange), .menuItemFont(UIFont(name: "HelveticaNeue", size: 15.0)!), .menuHeight(80.0), .menuItemWidth(90.0), .centerMenuItems(true) ] pageMenu = CAPSPageMenu( viewControllers: controllers, frame: CGRect( x: 0.0, y: 0.0, width: self.view.frame.width, height: self.view.frame.height ), pageMenuOptions: params ) self.addChildViewController(pageMenu!) self.view.addSubview(pageMenu!.view) pageMenu!.didMove(toParentViewController: self) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

1つ目のエラーですが、何のためにoverrideしようとしてるのか分かりませんがコメントアウトで良い気がします。
2つ目のエラーですが、alamofireのバージョンはいくつですか?とりあえずこう書いてみてください↓

swfit

1Alamofire.request(fetchFrom!,method: .get, parameters: ["":""], encoding: URLEncoding.default, headers: nil).responseJSON { response in

投稿2016/12/02 21:33

fromageblanc

総合スコア2724

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

pice

2016/12/04 01:59

ご回答ありがとうございます。 1つ目のエラーですが、コメントアウトしたところ、「Cannot assign to property: 'parent' is a get-only property」というエラーが出たため、「ViewController.swift」の「feedController.parent = self」もコメントアウトしました。 2つ目のエラーについて。 Alamofireのバージョンは4.2.0でした。 Xcode8.1、macOS10.12.1でビルドを試みていますが、関係がありますでしょうか。 挙げて頂いたコードを試したところ、ビルドした状態では、画面が真っ白になってしまいます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問