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

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

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

Xcode 7は、ソフトウェア開発のためのアップルの統合開発環境であるXcodeのバージョン。UIを作成するために用いるグラフィカルツールです。iOS9/OS X El Capitan/watchOS2に対応。Swift 2コンパイラーが搭載されています。

RSS

RSS(Really Simple Syndication)はブログのエントリやニュースの見出し、標準のフォーマットの音声やビデオなどを発行するために使われるウェブフィードのフォーマットの集合体です。

Q&A

1回答

1797閲覧

XcodeコンソールにRSSウェブデータ取得状態が表示されない。Xcodeの設定に問題?

tomo39-.

総合スコア27

Xcode 7

Xcode 7は、ソフトウェア開発のためのアップルの統合開発環境であるXcodeのバージョン。UIを作成するために用いるグラフィカルツールです。iOS9/OS X El Capitan/watchOS2に対応。Swift 2コンパイラーが搭載されています。

RSS

RSS(Really Simple Syndication)はブログのエントリやニュースの見出し、標準のフォーマットの音声やビデオなどを発行するために使われるウェブフィードのフォーマットの集合体です。

0グッド

0クリップ

投稿2018/01/05 08:28

編集2018/01/06 17:27

Xcode 7.3 でRSSフィードアプリを作ろうと思っているのですが、
RSSをGoogleが提供するJson形式に変換するAPIを通して、組み込んでみたのですが、
Xcodeコンソール上に何も反応がありません。ウェブデータが取得しているのかもDebug Areaに表示されないためうまくいっているのかわかりません。そもそもxcodeの設定の問題なのでしょうか?

こちらの記事を参考に進めています。
http://webfood.info/swift-rss-reader/

TableViewにURLから取得するデータが反映されません。
Podfile内に、ライブラリを作成しました。ウェブページ情報を取得したいです。

source 'https://github.com/CocoaPods/Specs.git' use_frameworks! platform :ios, '8.0' target 'RssReaderApp' do pod 'PageMenu' pod 'Alamofire' pod 'SwiftyJSON' end

TableViewController.swiftは

import UIKit import Alamofire import SwiftyJSON class TableViewController: UITableViewController { var fetchFrom: String? var parent: UIViewController? var entries: [Entry] = [] override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self tableView.dataSource = self self.tableView.registerNib(UINib(nibName: "FeedTableViewCell", bundle: nil), forCellReuseIdentifier: "FeedTableViewCell") Alamofire.request(.GET, fetchFrom!).responseJSON { response in if let values = response.result.value { JSON(values)["responseData"]["feed"]["entries"].forEach {i,value in self.entries.append(Entry( title: value["title"].string!, desc: value["content"].string!, link: value["link"].string! )) } self.tableView.reloadData() } } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.entries.count } override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { return 90 } override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("FeedTableViewCell", forIndexPath: indexPath) as! FeedTableViewCell let entry = self.entries[indexPath.row] cell.title.text = entry.title cell.desc.text = entry.desc return cell } }

FeedTableViewCell.swift

import UIKit class FeedTableViewCell: UITableViewCell { @IBOutlet weak var title: UILabel! @IBOutlet weak var desc: UILabel! override func awakeFromNib() { super.awakeFromNib() // Initialization code } override func setSelected(selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) // Configure the view for the selected state }

とEntrySwiftではtitle, desc, linkを String と定義しております。
これらによってセルに情報を提示したいのですが、やはり、APIデータに問題があるようです。

こちらが、ViewController.swiftのコードです。
ビルドは問題なくできます、エラーも出ずに、しかしAPI取得じのコンソールには何も表示されないので、無事に取得できていない模様です。

import UIKit import PageMenu class ViewController: UIViewController { var pageMenu : CAPSPageMenu? override func viewDidLoad() { super.viewDidLoad() var controllers : [UIViewController] = [] let 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.blackColor()), .ViewBackgroundColor(UIColor.whiteColor()), .SelectionIndicatorColor(UIColor.orangeColor()), .MenuItemFont(UIFont(name: "HelveticaNeue", size: 15.0)!), .MenuHeight(80.0), .MenuItemWidth(90.0), .CenterMenuItems(true) ] pageMenu = CAPSPageMenu( viewControllers: controllers, frame: CGRectMake( 0.0, 0.0, self.view.frame.width, self.view.frame.height ), pageMenuOptions: params ) self.addChildViewController(pageMenu!) self.view.addSubview(pageMenu!.view) pageMenu!.didMoveToParentViewController(self) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } }

何かXcode上で設定が間違っているのでしょうか?

APIを通したURL を変えてみると、

”App Transport Security has blocked a cleartext HTTP”とエラーメッセージがコンソールに表示されたので、 info.plistより、 App Transport Security Settingを追加して、
Allow Arbitrary Loads を作成し、"YES" を選択しました。

しかし、ビルドをしてもデータが取得しいる画面が上がってきません。

宜しくお願いします。

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

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

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

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

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

guest

回答1

0

コードをかくにんしてみては

投稿2019/03/26 15:05

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問