A Slice of App Pie

newsletter-banner-square

A Slice of App Pie:

The Newsletter and Podcast for Creative iOS Developers.

If you are making your own stuff, doing your own work and trying to sell it in the market, most advice isn’t enough. You want it to work. You want to sell your works  to those who most are touched by them. This newsletter is for you. I am one of those people like you, creative, independent and maybe a little bit crazy to the outside world. I’ll talk about writing good apps for Apple platforms, the tools and API’s to get there. Along the way I will show you how to become you best creative self too.  I will show you how to build and create, and make some money at it too.

Get exclusive content, new post notifications, tips and more in A Slice of App Pie. I have two formats available: You can read the content in the newsletter or listen on the podcast.

Sign up for the newsletter today. 

Subscribe to the podcast

12 Replies to “A Slice of App Pie”

  1. I made the example of the different kinds of cheese and gives me error code in two parts which are:

    func pickerView(pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
    let titleData = pickerData[row]
    var myTitle = NSAttributedString(string: titleData, attributes: [NSFontAttributeName:UIFont(name: “Georgia”, size: 15.0),NSForegroundColorAttributeName:UIColor.blueColor()])
    return myTitle
    } error: cannon invoice “init” with an argument list of type string: string attributes St9……

    another piece of code puts it:

    let titleData = pickerData[row]
    let myTitle = NSAttributedString(string: titleData, attributes: [NSFontAttributeName:UIFont(name: “Georgia”, size: 26.0),NSForegroundColorAttributeName:UIColor.blackColor()])
    pickerLabel!.attributedText = myTitle

    return pickerLabel

    Saludos.

  2. Thanks for replying, however I have sent an email where you see the error more precisely. I hope to have if we can find solution for this example and let me know so we can correct it for my example and thus also taken into account.

    Greetings and thanks.

    1. I have the solution.

      It turns out that in the latest version of Swift the UIFont is now optional. In order to put it in the attributes dictionary correctly you have to unwrap the optional. So the code now reads:

      var myTitle = NSAttributedString(string: titleData, attributes: [NSFontAttributeName:UIFont(name: "Georgia", size: 15.0)!,NSForegroundColorAttributeName:UIColor.blueColor()])

      Just add an exclamation point after the UIFont initializer, and your error should disappear.

      I updated the tutorial for this change, and I now have to go to the attributed string one and change it there too. Thank you for catching this error.
      Steve

  3. Hi Steve,
    thanks for the solution …. works !. Steve also appreciate the quick response and solution.

    What will fix the website where the example appears ?. Then the error is due to the Swift language, which has become the method in optional, which seeketh on documentation has since warned me of this, however if you have the link where I can study the particular change is the agradecere.

    Cheers and thanks again.

    J. Paul

    1. This is a big annoying Swift issue — I’ve edited about six posts since Apple started doing this. Unfortunately there isn’t any good documentation. Apple is in a process of changing some things to optional and others to non optional since September. They have not been documenting these well except in the class references. The only thing you can do (which is what I did) is option click on identifiers in XCode and see what type pops up.

      1. I was already aware that Swift was giving problems because you do not have well defined and clear Swift that’s a problem because you learn one thing and then comes Apple and then change it. Hopefully Apple and finished well deinir Swift and XCODE.
        We are in touch and congratulations on your website and your help.

        Greetings.

  4. Hi, I’m loving your blog so far… have read through quite a few posts on swift programming and I’m hooked.. there was a comment that you made in July about notifications (sending values/data through notifications instead of using segues and delegates) but I can’t seem to find it… unless its not out there yet… I’m quite interested to see what you have to say about that subject…
    To give you a background of my interest: I’m working on an app that uses CoreBluetooth and reads a characteristic. this is done on the first view controller, then I send that characteristic to a second view controller which must use the value to do something else… but doing it your segue way I can’t use the characteristic other than inside an IBAction, and while that is useful, if I want to set my notifications to true on the first view controller, the value will stay the same until the IBAction is changed, thus making the automatic update useless…

    How would you approach this issue? keep up the great work on your blog!

    1. there is a chapter In the book on property observers, don’t remember off the top of my head if it is in the free e-book. look at the tab bar controller entry in the website for it. I used property observers in tab bars. thoug I hate having anything in the app delegate, this may be one of those exceptions. you might set up a flag with a property observer in the app delegate that fires and executes something in your first controller on a change of state.

      1. Thanks for the quick response!, I do have a similar setup that looks for a change of flag however the action takes place In the second view controller, while the function has to happen on the first and while the flag IS triggered, the first view controller never runs the function I’m wondering whether it is because the active view is not the first view controller….

      2. if you are using a Navigation controller, yes that is what is happening. Only the controller on the top of the stack is really active, with the exception of delegates. Sounds like something that needs to be dealt with on a delegate.Delegates are not just for passing data back and forth when you close the controller, but can be for activating stuff as well — look at the UITableviewController or UIPicker for examples of this use of delegates for thier didSelect methods. Make a protocol with an abstract method to happen when your event happens. in you secnd controller, call the protocol method. set up the delegate n your first view controller to do what you need to do. Alternatively, you can use your delegate back to the first view controller to make the change you need in the first view controller. IF you have something that will change state a lot, but you don’t need to really do anything about until you go back, use method 2. if you need to make those changes every event, use method 1, though it will use a lot more cycles.

  5. Thanks! the change state isn’t expected to change a lot, however since its passing a value that is being updated constantly (CBPeripheral) and my first view controller has mainly a tableview that I do not wish to go back to unless I disconnect and have to re-select a peripheral I didn’t want to go back to the first view controller… Maybe it’d be easier using one of your methods but making use of the CBPeripheral in a different view controller…

    Thanks that was quite helpful!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s