Saturday, February 28, 2015

Fun with Swift recap

Since 2015 we added a number of Swift tutorials to this blog for Mac OS X and iOS. I mostly have focused on Mac because I discovered there not many code examples around the web for Mac and swift. iOS there thousands of them and many are very good.

I also have been making apps for the Mac since 1997 and would like to see so many more jump on board to the Mac OS platform. Users are actually willing to pay money for a Mac apps, unlike iOS where anything over $0.99 is frowned upon.

I going to recap  back to all of the 2015 post we made so far up to March 1st on Swift.

Saturday, January 17, 2015

Using Swift for Mac OS X apps


The basic intro of using strings.

view topic

Tuesday, January 20, 2015

Hello Mac From Swift


A video walk through of Xcode and how to make outlets and actions. How to setup UI Controls, Windows with layout constrains. How to use and combine text strings.

view topic

Friday, January 23, 2015

Make OS X Web Browser with Swift


A video showing how to make a basic web browser with swift, inculding adding Google search.

view topic

 Saturday, January 24, 2015

 Sliders with Swift


A basic look at how to uses the a slider control.

view topic

Tuesday, January 27, 2015

Alert Messages with Swift


A look at how to present a NSAlert

view topic

Saturday, February 14, 2015

Alerts with Swift for iOS


A look at how to use alerts with iOS.

view topic

Wednesday, February 18, 2015

64-bit requirement for iOS


Simple info about all app store apps require 64-bit support.

view topic

Wednesday, February 18, 2015

Tabbar for iOS with Swift


A video to show how to add more tabs to a iOS tab view app.

view topic

Friday, February 20, 2015

Swift language update


Info about Apple beta release of Swift version 1.2

view topic

Saturday, February 21, 2015

Xcode swift tip: Access to docs fast


A tip on how to access header files fast in Xcode to quickly speed up development.

view topic

Monday, February 23, 2015

Swift for Mac Cocoa: Radio Buttons


A video show how to program with Radio Buttons and NSMatrix with Swift.

view topic

Wednesday, February 25, 2015

Swift for Mac: Programming Image Views


Another video showing how to load bundle images and present them on screen.

view topic

Thursday, February 26, 2015

Swift for cocoa importing files with open panel


Another video showing how to use a open panel to import and read files selected by the user.

view topic 

See All Swift Posts

View



I will be adding more swift examples this year, however I will also be focusing back on cross platform also.

Thanks and happy coding ;)

Thursday, February 26, 2015

Swift for cocoa importing files with open panel

 Today we look at programming a open panel to import files that the user selects. Most apps do things with files so this is really a good thing to know. With swift this is pretty simple and I think you will find the example easy to do your self.




My example will show importing images that the your selected, but this same panel can open anything. From text, movies, music, folders etc.

Here the video showing how to add open files to a cocoa app using swift:



Thanks again, Happy Coding ;)

Wednesday, February 25, 2015

Swift for Mac: Programming Image Views

Today's Swift example shows how to display images “photos” in a cocoa based app. It is actually easier with Swift and Xcode, than with most third party development tools I used.

Video to watch is here:



Thanks, happy coding ;)

Monday, February 23, 2015

Swift for Mac Cocoa: Radio Buttons

When it comes to Swift for Mac OS X cocoa there very little info to be found anywhere. Google very rarely returns anything useful. The only swift examples found for the most part are for iOS not Mac. The two platforms are not really the same even if they use the same programming languages

Personally I want to use Swift for everything, because I really like it. It is possible to inter-mix Swift and Objective-C but why? Apple set up Swift to work completely on its own two feet.

Today is a basic example on how to use AppKits Radio Buttons for a Mac cocoa base app. I go over how to get which radio the user clicked on and how to set a highlighted radio cell by swift code.

I have a video showing you this in full, Here a my video on YouTube:



Thanks, happy coding ;)



Saturday, February 21, 2015

Xcode swift tip: Access to docs fast

I discovered a faster way to access docs for a certain item already in your code. For those who may not be aware of this tip I like to share it with you, because I think you may like it.

Say you want to know what available to use for UIViewController. my simply command clicking on that text in the code editor will bring up the header file for the selected item. This making it super fast to find what you could use.

The Example below shows the UIViewController with a command click.

This will make the header for this class appear in the edit view.


This makes finding info to what you need to use extremely fast and helpful. I find it better than searching the help Api docs as it returns everything for the selected item.

Thanks, and happy coding ;)

Friday, February 20, 2015

Swift language update

Apple recently announced the Swift  language will soon be entering version 1.2 and with that it will bring several notable changes.

All of the examples I shown part of this blog up to now use Swift v 1.1,  Note I will continued to show Swift version 1.1 until Apple officially releases this new Swift version as GM public release. I am not able to show pre-released , based on my license with Apple.

Currently Swift Version 1.2 is in beta and can be used with Xcode beta 6.3. (this if you have an active Mac and or iOS developer license). You can learn more about it at Apple Swift Blog. Also note there said to be a migration tool that will be able to convert your swift version 1.1 code bases to version 1.2, which should be a major plus.

If your interested in swift I highly suggest you follow Apple swift blog for the new language changes and tips. Swift Blog Here You also can follow the blog va Twitter @SwiftLang



Wednesday, February 18, 2015

Tabbar for iOS with Swift

Working with Xcode and Swift is really simple. I keep getting amazed how fast and simple it is to use.

I keep getting people telling me that Swift and Xcode is hard. Also have some say it is s not as fast as Xojo or Livecode for iOS or Mac OS. Actually for iOS and Mac OS its just as fast if not faster. It is really not that hard once you grasp the basics of Swift and learn the ins and outs of Xcode. 



Today we look at using  Xcode and Swift for a iOS interface, Tab bar views. Xcode comes with a template with two such tabs. My video will go over what you need to do to add more tabs to your tab view controller. Its under 5 minutes long. So enjoy.

Video:



Thanks for watching, Happy Coding.



64-bit requirement for iOS

The app store now requires all iOS builds be built for 32/64 bit binaries. If your using Xcode then this is nothing new. However if your using a 3rd party development tool you need to make sure all apps submitted are compiled to a 32/64 bit universal binary and by Summer 2015 all apps submitted before 2015 also are built with that requirement.

If your using Xojo for iOS the new released 2015 r1 supports this new iOS requirement. If your using Livecode for iOS the new release 6.7.2 or later supports this for Livecode. And if your using Xcode its business as usual, as it been supporting this for a while now.

For Xojo 2015 r1 (released 2/17/2015)  get it here
For Livecode 6.7.2 (released 2/17/2015)  get it here
For Xcode 6.1.1 (released 12/02/2014)  get it here

Saturday, February 14, 2015

Alerts with Swift for iOS

A few weeks ago I went over alerts with swift for Mac OS X. Well just to show how different alerts are between Mac OS X and iOS well take a look at several different type of alerts that can be used with iOS with swift.


First is the most basic alert that includes a title, message and up to 3 action buttons.



below is the code to set up the alert, and call it when a user taps on the button; btnShowAlert

//button action:
@IBAction func btnShowAlert(sender: AnyObject) {
      
       // set up the alert view
        let alertController = UIAlertController(title: "Hello World", message: "this is the obleo's alert message", preferredStyle: UIAlertControllerStyle.Alert)
       
       //set up the action button
        alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
       
        // show a alert view
        self.presentViewController(alertController, animated: true, completion: nil)
    }




That a little different to what we did with Mac OS X and swift. It has more code (however if you have auto complete on, most of its filled in for you.)

Another type alert that I use often is the alert with a text field. It has all the same options as above but includes a text field on the alert. ( you can have several fields if wanted, my example below screen shot show just one.)




To set up the alert with the field is not much different than the normal alert. There is just two added lines of code needed different than an normal alert. 1) add the field to the alert with addTextFieldWithConfigurationHandler and 2) setting up way to get the text added to the text field.

see code below:

//button action:
@IBAction func btnShowAskAlert(sender: AnyObject) {
        
// set up alert view
        let alertTextController = UIAlertController(title: "Your Name", message: "Name:", preferredStyle: UIAlertControllerStyle.Alert)
       
        // add the field to the alert (new)
        alertTextController.addTextFieldWithConfigurationHandler ({ (mainTextfld) -> Void in mainTextfld.text = "Add Your name"; })
       
        //add a button action
        alertTextController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (action) -> Void in
           
            // add code to preform action from user tapping OK button (new)
            let mainTextfld = alertTextController.textFields![0] as UITextField
            // present result on screen in UIText
            self.fldResult.text = mainTextfld.text
        }))
       
        // present the alert with field on screen
        self.presentViewController(alertTextController, animated: true, completion: nil)
       
        }

That it, swift is just amazing no mater if your targeting Mac or iOS. I noticing that swift for Mac is actually easier than iOS and is less lines of code than iOS for many of the same type of things.

Happy Coding ;)
 
PS I know its been a few weeks since I made a video, my old MBP finally died. I ran into issue with screenflow 3 is not working with my new Mac, I need to update screenflow to version 5+ and do not have the  extra cash today to make it happen. ( And yes I tried quicktime, but it not as professional as screenflow)