Help with dictionaries and updating from a server

Discussion in 'iOS Programming' started by noobcodered, Jan 30, 2016.

  1. noobcodered macrumors newbie

    Jan 29, 2016
    Let me start by saying, I'm an artist at heart, not a programmer. I've been hacking and clawing my way through the app development process, learning as I go. I have an issue that I need help in figuring out the best way to address it.

    I have an app that periodically gives information on upcoming sales in the area, each time displaying the date, address, and a map that kicks out to the Maps app upon clicking it. The app that I've made currently uses a WebView to display updated sale/address information as if it were a page within the app. I did this because 1) I couldn't figure out how to update the text strings displaying the dates and address for the sale from a server, and 2) I couldn't figure out how to make the clickable Maps address update either. It was easier just to display a webpage inside a WebView as if I were doing it the "proper" way that I didn't know how to do.

    Now I need to figure out this stuff because I'm trying to expand this app onto the Apple Watch. Now I know that I can use Dictionaries to update these strings from an XML file on the server (dictionaryfromURL or something like that, I don't have the documentation open). I don't know anything about JSON, or Databases, so I was just planning on doing the XML method to define the key and string values. The way I understand it, I can reference the key to get the value and then display the text that way with a UILabel. Seems pretty simple.

    However, after doing some digging, it's not as simple as it seems. I've read a bunch of stuff about needing to parse the XML and this and that. I downloaded a sample project from Apple called XML performance that seems to do what I want (i.e. updating the string values via XML), but there's so much going on in the code that I know it can't be THAT complicated to do what I'm trying to do. I just need to display a few lines of text and have the clickable maps address also be updated from that dictionary.

    What's the best way to go about this? Am I totally off the mark?
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    Use JSON if at all possible. Parsing JSON is a one-liner. No need to write an xml parser. You get a dictionary back inside your JSON.

    Let me just say though that if you're not prepared to learn to code things the right way you'll almost certainly hit a wall sooner or later. The best way to learn is by a book or online course.
  3. noobcodered thread starter macrumors newbie

    Jan 29, 2016
    Thanks for the quick and simple answer. I'll do my reading. It's a lot easier when I know what to look for and what to use to do what I'm trying to do. The amount of information and ways to do things is just so immense, and I didn't even know about, or have a need for dictionaries until now. There's a lot to take in as a newcomer, especially teaching myself things, and still trying to keep it fun.

    On top of the other life obligations and whatnot.

    I didn't say I wasn't prepared to learn to code things the right way, I just didn't even know how to go about doing it the right way until now. Unless you mean that in the sense of actually learning how to code, then it's also not that I'm not prepared to do it, it's that I have other obligations that prevent me from dedicating the amount of time required for it right now. I'm still just getting my feet wet and trying things out. I don't profess to be a professional. :)

    I do have some good e-books that I still have to delve into. Nerd Ranch's book on Objective C seems to be highly-regarded, and I have a few others. I also enjoyed Treehouse when I had the money to pay for the lessons, and they're pretty comprehensive it seems. So I'll try to figure out the JSON thing because I really like the idea of one-liner code and logical referencing instead of all this parsing business with a paragraph of code. I can code simple things, logically. I understand the basics of how things work logically, and I've done some things already, it's just the coding part that gets me sometimes because I don't know a lot of what's out there. I have a background in web design, way back when it was still simple to do. Just HTML/CSS stuff. So that helps a little.

Share This Page