Working in simulator but not on device i am getting data from api it's properly work on simulator but not working in real device
And gives a error No such module 'Alamofire'
here is my code ViewController.swift
import UIKit
import Alamofire
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
@IBOutlet var tableview: UITableView!
var TeamArray = [AnyObject]()
var BackArray = [AnyObject]()
var countnew = 0
var timer = Timer()
override func viewDidLoad() {
super.viewDidLoad()
Alamofire.request("https://www.WebLink.com/api/").responseJSON{
response in
if let DataResult = response.result.value{
if let dictionary = DataResult as? [String: Any] {
if let Result1 = dictionary["result"] as? [String: Any]{
if let nestedDictionary1 = Result1["inPlayEvents"] as? NSArray, let description = nestedDictionary1.value(forKey: "market") as? [[String: Any]],let description1 = description.first?["runners"] as? [[String: Any]],let BAck = description1.first?["back"] as? NSArray{
print("JSONResdsd : \(nestedDictionary1)")
// print("JSONEvent : \(description)")
self.TeamArray = description as [AnyObject]
self.BackArray = BAck as [AnyObject]
self.timer = Timer.scheduledTimer(timeInterval:1.0, target: self, selector: "sayHello", userInfo: nil, repeats: true)
}
}
}
}
}
// Do any additional setup after loading the view, typically from a nib.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return TeamArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as?
CustomTableViewCell
let title = TeamArray[indexPath.row]["start"]
let price = BackArray[indexPath.row]["price"]
let x : Double = title as! Double
let myString = String(x)
let pricenew : Double = price as! Double
let pricestr = String(pricenew)
print("Price : \(pricestr)")
print("INT : \(title)")
//let BPrice = BackArray[indexPath.row]["price"]
// ToastView.shared.short(self.view, txt_msg: "HJJDFKH\(String(describing: BPrice)))")
cell?.TitleLabel.text = String (myString)
cell?.Back.text = String (pricestr)
// cell?.Back.text(\())
return cell!
}
@objc func sayHello()
{
self.tableview.reloadData()
}
}
Could you tell me how did you install Alamofire? As you can check on their GitHub readme page: https://github.com/Alamofire/Alamofire/tree/4.8.0 there are a few ways to add this library to project. I will recommend you using Cocoapods:
1) Install CocoaPods:
gem install cocoapods
2) Create Podfile
inside your project folder:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'Alamofire', '~> 4.7'
end
Replace <Your Target Name>
with your target name.
3) Run:
pod install
4) Close your project and open a new file called <Your Project Name>.xcworkspace
in Xcode