I am successfully appending "title" , "url" and Video in these Global Variables but when I am trying to use in numberOfRowsInSection as ( return titleName.count ) so I am getting nil or in (cellForRowAt indexPath: ) as cell.videoTitle.text = titleName[indexPath.row] so I am getting nil..
Globalvariables is ...
var titleName:[String] = []
var videoID:[String] = []
var valueKey:[String] = []
and then in viewDidLoad()
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
let urlRequest = URL(string: urlString)
URLSession.shared.dataTask(with: urlRequest! , completionHandler:{(data, response, error) -> Void in
if (error != nil ){
print(error.debugDescription)
} else {
do{
if let jsonObject = try?JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [String : AnyObject] {
if let itemsArray = jsonObject?["items"] as? [[String:AnyObject]]{
for snippetArray in itemsArray{
if var snippet = snippetArray["snippet"] as? [String : AnyObject]{
if let titleItems = snippet["title"] as? String{
self.titleName.append(titleItems)
}
if let thumbnail = snippet["thumbnails"] as? [String : AnyObject]{
if let highValue = thumbnail["high"] as? [String : AnyObject]{
if let urlValueKey = highValue ["url"] as? String{
self.valueKey.append(urlValueKey)
}
}
}
if let resource = snippet["resourceId"] as? [String : AnyObject]{
if let videoId = resource["videoId"] as? String{
self.videoID.append(videoId)
}
}
}
}
}
}
} catch let error as NSError {
print(error)
}
}
}).resume()
tableView.reloadData()
}
and here is the JSOn....
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/ep-DtNxjJwMQbpCO1Lk3_ggMScU\"",
"nextPageToken": "CAUQAA",
"pageInfo": {
"totalResults": 1636,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#playlistItem",
"etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/SYrDBZ2Ywgpf3zgCreEdB4PIf1o\"",
"id": "UUZwDRPIG5DD2lxeCjap51NdbKiDO_M62c",
"snippet": {
"publishedAt": "2015-06-25T01:50:54.000Z",
"channelId": "UCK8sQmJBp8GCxrOtXWBpyEA",
"title": "The Google app: Summer",
"description": "\"OK Google, when is Summer over?\"\n\nTalk to Google to get answers, find stuff nearby, and get things done. The Google app. Available on iOS and Android. \n\nDownload the app here: http://www.google.com/search/about/download/",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/BVGKskYZrw8/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/BVGKskYZrw8/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/BVGKskYZrw8/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/BVGKskYZrw8/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/BVGKskYZrw8/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "Google",
"playlistId": "UUK8sQmJBp8GCxrOtXWBpyEA",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": "BVGKskYZrw8"
}
}
},
... MORE ITEMS ...
]
}
dataTask(with works asynchronously. Move tableView.reloadData() into the completion block at the end of the closure.
Two notes:
A JSON dictionary in Swift 3 is [String:Any].
You are discouraged from using multiple arrays as data source. Use a custom struct or class.
Your code snippets above missing the portion where you retrieve the JSON into the data that was later used by the JSONSerialization in viewDidLoad().
As example of a complete snippet, please check the question in this thread: How to get json to populate UITableView in Swift 3?
Related
My get data response is like
I want "title" and "date" should be shown in my view controller "label values"
get method calls when app running and the data should display in either text fields "or" in label
My Code is
guard let url = URL(string: "https://jsonplaceholder.typicode.com/users") else { fatalError() }
let session = URLSession.shared
session.dataTask(with: url) { (data, response, error) in
if let response = response {
print(response)
}
if let data = data {
print(data)
do {
let json = try JSONSerialization.jsonObject(with: data, options: [])
print(json)
} catch {
print(error)
}
}
}.resume()
out put is :
[
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere#april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
},
{
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "Shanna#melissa.tv",
"address": {
"street": "Victor Plains",
"suite": "Suite 879",
"city": "Wisokyburgh",
"zipcode": "90566-7771",
"geo": {
"lat": "-43.9509",
"lng": "-34.4618"
}
},
]
I want to print "username":
"email":
values in my Storyboard labels
The result contains multiple users, so you should first iterate over them and find the user you want. Then you can set text on your UI elements in the Main thread.
guard let url = URL(string: "https://jsonplaceholder.typicode.com/users") else { fatalError() }
typealias User = [String: Any]
let session = URLSession.shared
session.dataTask(with: url) { (data, response, error) in
if let response = response {
print(response)
}
if let data = data {
print(data)
do {
let usersJson = try JSONSerialization.jsonObject(with: data, options: []) as! [User]
print(usersJson)
// Since the result is an array of users
for user in usersJson {
guard let userName = user["username"] as? String else { return assertionFailure("Invalid username") }
print(userName)
// All UI works should done in main thread
DispatchQueue.main.async {
<#usernameLabel#>.text = username
}
}
} catch {
print(error)
}
}
}.resume()
I suggest you take a look at Swift Codable. It will boost your coding and minimize syntax and human errors.
Hi have an application which collects data from an api and I use Alamofire and swiftyJSON. the current challenge I am facing now is that I have different dictionaries in one array and I want to be able to retun back specific items in the dictionary. this is the array I am working with
Json
[
{
"images": [
{
"id": 8,
"original": "http://127.0.0.1:8000/media/images/products/2018/05/f3.jpg",
"caption": "",
"display_order": 0,
"date_created": "2018-05-26T17:24:34.762848Z",
"product": 13
},
{
"id": 9,
"original": "http://127.0.0.1:8000/media/images/products/2018/05/f5.jpg",
"caption": "",
"display_order": 1,
"date_created": "2018-05-26T17:24:34.815214Z",
"product": 13
},
{
"id": 10,
"original": "http://127.0.0.1:8000/media/images/products/2018/05/f2.jpg",
"caption": "",
"display_order": 2,
"date_created": "2018-05-26T17:25:19.117271Z",
"product": 13
},
{
"id": 11,
"original": "http://127.0.0.1:8000/media/images/products/2018/05/f4.jpg",
"caption": "",
"display_order": 3,
"date_created": "2018-05-26T17:25:19.155159Z",
"product": 13
}
]
}
]
get a single image is like this
Alamofire.request(URL, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: HEADER).responseJSON { (response) in
if response.result.error == nil {
guard let data = response.data else {return}
do {
if let json = try JSON(data: data).array {
for item in json {
let images = item["images"][0]["original"].stringValue
....
this returns only the indexed image.[0] if it is set to [1] it returns the indexed image at 1.
how do I return all the images so that I can loop through all and display in a collection view controller. more codes would be supplied on request.
You can dit it Like that :
if let json = try? JSON(data: data).arrayValue {
for item in json {
let imagesList = item["images"].arrayValue
let imagesURL = imagesList.map {$0["original"].string}.compactMap({$0})
if imagesURL.count > 0{
print( imagesURL[0])
}
}
}
Or:
do {
let json = try JSON(data: data).array
json?.forEach({ (item) in
let imagesList = item["images"].arrayValue
let imagesURL = imagesList.map {$0["original"].string}.compactMap({$0})
if imagesURL.count > 0{
print( imagesURL[0])
}
})
} catch {
print(error.localizedDescription)
}
I am trying to retrieve the featureclass inside the GeoJSON below.
I have updated the GeoJSON below.
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"scalerank": 8,
"name": "Grill",
"website": "www.rocargo.com/SanNicolas.html",
"natlscale": 5,
"featureclass": "Meat"
},
"geometry": {
"type": "Point",
"coordinates": [-11.1086263, 59.1438153]
}
},
{
"type": "Feature",
"properties": {
"scalerank": 8,
"name": "Queen Vic",
"website": "www.rocargo.com/SanNicolas.html",
"natlscale": 5,
"featureclass": "Fish"
},
"geometry": {
"type": "Point",
"coordinates": [-11.1190539, 59.1498404]
}
},
{
"type": "Feature",
"properties": {
"scalerank": 8,
"name": "Josephines",
"website": "www.rocargo.com/SanNicolas.html",
"natlscale": 5,
"featureclass": "Bar"
},
"geometry": {
"type": "Point",
"coordinates": [-11.1145087,59.142496]
}
},
{
"type": "Feature",
"properties": {
"scalerank": 8,
"name": "Fall",
"website": "www.rocargo.com/SanNicolas.html",
"natlscale": 5,
"featureclass": "Port"
},
"geometry": {
"type": "Point",
"coordinates": [-11.1174109, 59.1402164]
}
}
]
}
The below function can pull all the information above.
func pleaseWork() {
let urlBar = Bundle.main.path(forResource: "bars", ofType: "geojson")!
if let jsonData = NSData(contentsOfFile: urlBar) {
do {
if let jsonResult: NSDictionary = try JSONSerialization.jsonObject(with: jsonData as Data, options: JSONSerialization.ReadingOptions.mutableContainers) as? NSDictionary {
if let responseA : NSArray = jsonResult["features"] as? NSArray {
print(responseA)
}
}
}
catch { print("Error while parsing: \(error)") }
}
I can pull all the information however, I am struggling to get the 'featureclass' information. What steps am I missing?
Thanks.
asdfadsfadsfdsafdsafdsfadsfdsafdsafdasf asdfasdfadsfdsa
I recommend to use Decodable in Swift 4. It's very simple and convenient
Create the structs
struct Collection : Decodable {
let type : String
let features : [Feature]
}
struct Feature : Decodable {
let type : String
let properties : Properties
// there is also geometry
}
struct Properties : Decodable {
let scalerank : Int
let name : String
let website : URL
let natlscale : Int
let featureclass : String
}
Decode the data and print the values for name and featureclass
let urlBar = Bundle.main.url(forResource: "bars", withExtension: "geojson")!
do {
let jsonData = try Data(contentsOf: urlBar)
let result = try JSONDecoder().decode(Collection.self, from: jsonData)
for feature in result.features {
print("name", feature.properties.name, "featureclass", feature.properties.featureclass)
}
} catch { print("Error while parsing: \(error)") }
Step by Step only, you can achieve that.
if let responseA : NSArray = jsonResult["features"] as? NSArray {
for dictVal in 0..<responseA.count
{
let featuresDict = responseA[dictVal] as! NSDictionary
let propertiesDict = featuresDict.value(forKey: "properties") as! NSDictionary
let featureClassName = propertiesDict.value(forKey: "featureclass") as! String
print(featureClassName)
}
}
Try to use this link for Complex JSON validation. You will get clarity.
{
"items": [
{
"startTime": "1498667581661",
"endTime": "1498667821661",
"dateTime": "2017-06-28T16:33:01.661Z",
"totalTime": "4",
"auctionName": "Bbbb",
"status": 1,
"id": "4760417733705728",
"kind": "auctionTimeApi#resourcesItem"
},
{
"startTime": "1498772812087",
"endTime": "1498772992087",
"dateTime": "2017-06-29T21:46:52.087Z",
"totalTime": "3",
"auctionName": "sdasdasdd",
"status": 1,
"id": "5080491044634624",
"kind": "auctionTimeApi#resourcesItem"
},
{
"startTime": "1498833895423",
"endTime": "1498834375423",
"dateTime": "2017-06-30T14:44:55.423Z",
"totalTime": "8",
"auctionName": "Boston",
"status": 1,
"id": "5085211482128384",
"kind": "auctionTimeApi#resourcesItem"
},
{
"startTime": "1498767894987",
"endTime": "1498768254987",
"dateTime": "2017-06-29T20:24:54.987Z",
"totalTime": "6",
"auctionName": "Dfddd",
"status": 0,
"id": "5111065843073024",
"kind": "auctionTimeApi#resourcesItem"
},
{
"startTime": "1498640043323",
"endTime": "1498640283323",
"dateTime": "2017-06-28T08:54:03.323Z",
"totalTime": "4",
"auctionName": "Andsda",
"status": 1,
"id": "5118511437316096",
"kind": "auctionTimeApi#resourcesItem"
},
{
"startTime": "1498807228606",
"endTime": "1498807348606",
"dateTime": "2017-06-30T07:20:28.606Z",
"totalTime": "2",
"auctionName": "Dxf",
"status": 1,
"id": "5146118144917504",
"kind": "auctionTimeApi#resourcesItem"
},
{
"startTime": "1498806518484",
"endTime": "1498807358484",
"dateTime": "2017-06-30T07:08:38.484Z",
"totalTime": "14",
"auctionName": "rrrtttt",
"status": 1,
"id": "5151952589553664",
"kind": "auctionTimeApi#resourcesItem"
},
{
"startTime": "1498807683483",
"endTime": "1498807863483",
"dateTime": "2017-06-30T07:28:03.483Z",
"totalTime": "3",
"auctionName": "wwew",
"status": 1,
"id": "5956451503702016",
"kind": "auctionTimeApi#resourcesItem"
},
{
"startTime": "1498803576630",
"endTime": "1498803816630",
"dateTime": "2017-06-30T06:19:36.630Z",
"totalTime": "4",
"auctionName": "zzzz",
"status": 0,
"id": "5964732200648704",
"kind": "auctionTimeApi#resourcesItem"
},
{
"startTime": "1498833083854",
"endTime": "1498833563854",
"dateTime": "2017-06-30T14:31:23.854Z",
"totalTime": "8",
"auctionName": "Dartmouth",
"status": 0,
"id": "6314781967384576",
"kind": "auctionTimeApi#resourcesItem"
}
],
"kind": "auctionTimeApi#resources",
"etag": "\"l-71RhD3VMYkQ-s_W643oBlpkCw/1SZlmWzcSB8XxEnhJpjVvwPV5k4\""
}
Above is my JSON data in the Google cloud
Add This is my SWIFT3 code:
import UIKit
class ViewController: UIViewController , UITableViewDataSource {
#IBOutlet weak var auctionLabel: UILabel!
#IBOutlet weak var auctionTableView: UITableView!
var fetchAuctionName = [AuctionName]()
override func viewDidLoad() {
super.viewDidLoad()
auctionTableView.dataSource = self
parseData()
}
override var prefersStatusBarHidden: Bool {
return true
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return fetchAuctionName.count
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = auctionTableView.dequeueReusableCell(withIdentifier: "cell")
cell?.textLabel?.text = fetchAuctionName[indexPath.row].auctionname
cell?.detailTextLabel?.text = fetchAuctionName[indexPath.row].auctionname
return cell!
}
func parseData() {
fetchAuctionName = []
let url = "urll"
var request = URLRequest(url: URL(string: url)!)
request.httpMethod = "GET"
let configuration = URLSessionConfiguration.default
let session = URLSession(configuration: configuration, delegate: nil, delegateQueue: OperationQueue.main)
let task = session.dataTask(with: request) { (data, response, error) in
if (error != nil){
print("Error")
}
else{
do{
let fetchData = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! NSDictionary
let jsonArray = fetchData.value(forKey: "items") as! NSArray
for eachFetchedAuctionName in jsonArray {
let eachAuctionName = eachFetchedAuctionName as! [String : Any]
let auctionname = eachAuctionName["auctionName"] as! String
self.fetchAuctionName.append(AuctionName(auctionname: auctionname));
}
self.auctionTableView.reloadData()
}
catch{
print("Error 2")
}
}
}
task.resume()
}
}
class AuctionName: NSObject {
var auctionname : String
init(auctionname : String) {
self.auctionname = auctionname
}
}
With this code I can print all the status values from the JSON data
My question is; I just need those with a status value of 0 to be printed. How can I modify my code to achieve this?
Try this
func parseData() {
fetchAuctionName = []
let url = "urlllll"
var request = URLRequest(url: URL(string: url)!)
request.httpMethod = "GET"
let configuration = URLSessionConfiguration.default
let session = URLSession(configuration: configuration, delegate: nil, delegateQueue: OperationQueue.main)
let task = session.dataTask(with: request) { (data, response, error) in
if (error != nil){
print("Error")
}
else{
do{
let fetchData = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! NSDictionary
let jsonArray = fetchData.value(forKey: "items") as! NSArray
for eachFetchedAuctionName in jsonArray {
let eachAuctionName = eachFetchedAuctionName as! [String : Any]
let auctionname = eachAuctionName["auctionName"] as! String
if let status = eachAuctionName["staus"] as? Bool{
if status == true{
self.fetchAuctionName.append(AuctionName(auctionname: auctionname));
}
}
}
self.auctionTableView.reloadData()
}
catch{
print("Error 2")
}
}
}
task.resume()
}
}
for eachFetchedAuctionName in jsonArray {
let eachAuctionName = eachFetchedAuctionName as! [String : Any]
let auctionname = eachAuctionName["auctionName"] as! String
self.fetchAuctionName.append(AuctionName(auctionname: auctionname));
// you can typecast to either String or an Int and then compare it respectively
//with a String "1" or an Int(1), whichever suits your app
guard let status = eachAuctionName["status"] as! Int else { return }
if status == 0 {
print("0 found")
}
}
One suggestion: use swift 4 Decodable protocol, to parse JSON easily into custom objects either a struct or a class of your choice, makes the code looks nice and clean.
On the below method, I can get the place value but not the location value. how can I get the location?
Thank you in advance!!
func searchDB(looking: String){
var urlString:String = "URLGOESHERE?q=\(looking)"
let url = NSURL(string: urlString)
let session = NSURLSession.sharedSession()
let task = session.dataTaskWithURL(url!, completionHandler: { (data, response, error) -> Void in
if error != nil {
println(error)
}
else {
//processing data
if let arr = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil) as? [AnyObject] {
for currPlace in arr {
println(currPlace["name"])
println(currPlace["location"])
}
}
else {
errorOccurred = true
}
}//eo potential data
})
task.resume()
}//eom
This is the result output I am getting:
Optional(Buddha-Bar)
Optional(nil)
JSON sample:
sample data:
{
"formatted_address": "8-12 Rue Boissy d'Anglas, 75008 Paris, France",
"geometry": {
"location": {
"lat": 48.868194,
"lng": 2.321596
}
},
"icon": "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png",
"id": "560dd225114fd10997f75ee777bad84bcb40c529",
"name": "Buddha-Bar",
"opening_hours": {
"open_now": true,
"weekday_text": []
},
"photos": [
{
"height": 848,
"html_attributions": [],
"photo_reference": "CnRnAAAAifUh9MiqwAgQYdwEp-EnS4e_nPQN_mPYIqdI49UKun_CZKxgtUh_ZqT8QBEqBuel9seoZvyyIVvA5-TlweEqO9_2tORg_cmTi_Cy5L_PAthdZd1_Krqbf7oJNy81RWD3brA8fzeIKJfQTMgo-AT19RIQAg5kKSqeoeedm69uhUWKvBoULDJ1-PoSgv4Lsg5y1rjU_pHm_Ng",
"width": 1919
}
],
"place_id": "ChIJRS81ac1v5kcRRUqQBmTTJJU",
"price_level": 3,
"rating": 3.7,
"reference": "CmReAAAAjJskNN69nw3gBVtqLpsX11Psr-QvK6cHPLhF-oDXAbYq7dwLn65b1svUJOLVnRgAbg4K3w7qCj9_hkXvx20q4YNR2714ZQQw89GyFGCtXAxonRh09_uvgK97DewsYRyUEhAczR_GzOvU0mmG1OZr0X3kGhQeJ1Vr3RSnI6VXyzh83W_LIcUK_g",
"types": [
"bar",
"restaurant",
"food",
"establishment"
]
},
Json data without spaces
sample data:
{
"formatted_address": "8-12 Rue Boissy d'Anglas, 75008 Paris, France",
"geometry": {
"location": {
"lat": 48.868194,
"lng": 2.321596
}
},
"icon": "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png",
"id": "560dd225114fd10997f75ee777bad84bcb40c529",
"name": "Buddha-Bar",
"opening_hours": {
"open_now": true,
"weekday_text": []
},
"photos": [
{
"height": 848,
"html_attributions": [],
"photo_reference": "CnRnAAAAifUh9MiqwAgQYdwEp-EnS4e_nPQN_mPYIqdI49UKun_CZKxgtUh_ZqT8QBEqBuel9seoZvyyIVvA5-TlweEqO9_2tORg_cmTi_Cy5L_PAthdZd1_Krqbf7oJNy81RWD3brA8fzeIKJfQTMgo-AT19RIQAg5kKSqeoeedm69uhUWKvBoULDJ1-PoSgv4Lsg5y1rjU_pHm_Ng",
"width": 1919
}
],
"place_id": "ChIJRS81ac1v5kcRRUqQBmTTJJU",
"price_level": 3,
"rating": 3.7,
"reference": "CmReAAAAjJskNN69nw3gBVtqLpsX11Psr-QvK6cHPLhF-oDXAbYq7dwLn65b1svUJOLVnRgAbg4K3w7qCj9_hkXvx20q4YNR2714ZQQw89GyFGCtXAxonRh09_uvgK97DewsYRyUEhAczR_GzOvU0mmG1OZr0X3kGhQeJ1Vr3RSnI6VXyzh83W_LIcUK_g",
"types": [
"bar",
"restaurant",
"food",
"establishment"
]
},
Adding a little formatting to the pertinent part of the data:
sample data: {
"formatted_address": "8-12 Rue Boissy d'Anglas, 75008 Paris, France",
"geometry": {
"location": {
"lat": 48.868194,
"lng": 2.321596
}
},
"icon": "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png",
"id": "560dd225114fd10997f75ee777bad84bcb40c529",
"name": "Buddha-Bar",
It is unclear what "sample data:" means as it is not quoted, it may be something added by the print statement (my guess) in which case it is not needed to access the components.
The name would be addresses as:
["name"]
The location is in lat/lon so there will be two accesses:
["geometry"]["location"]["lat"]
["geometry"]["location"]["lon"]
In the above the applicable language syntax must be applied, in Swift there will be some pain.
See json.org for information on JSON.
After some frustration and game of thrones. the messy solution was the one below.
an alternative may be api like
https://github.com/lingoer/SwiftyJSON
func searchDB(looking: String){
var errorOccurred:Bool = false
var urlString:String = "URLGOESHERE?q=\(looking)"
let url = NSURL(string: urlString)
let session = NSURLSession.sharedSession()
let task = session.dataTaskWithURL(url!, completionHandler: { (data, response, error) -> Void in
if error != nil {
println(error)
errorOccurred = true
} else {
// println(response) //response from post
//processing data
let jsonObject : AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil)
if let statusesArray = jsonObject as? NSArray{
println("********* LEVEL 1 *******")
println(statusesArray[0])
if let aStatus = statusesArray[0] as? NSDictionary{
println("********* LEVEL 2 *******")
println(aStatus)
if let geometry = aStatus["geometry"] as? NSDictionary{
println("********* LEVEL 3 *******")
println(geometry)
if let currLocation = geometry["location"] as? NSDictionary{
println("********* LEVEL 4 *******")
println(currLocation)
println(currLocation["lat"])
println(currLocation["lng"])
}
}
}
}
else {
errorOccurred = true
}
}//eo potential data
})
task.resume()
}//eom