Coding Explorer Blog

Exploring how to code for iOS in Swift and Objective-C

  • Home
  • Apps
  • About
  • Contact

Archives for April 2014

Add sharing to your app via UIActivityViewController

Last updated on November 10, 2014

Ever wonder what various apps like Photos or Safari use when you click on the share button? So did I until a few days ago. It is apparently UIActivityViewController. I just learned a bit about how to use it, so I thought I would pass it along.

Update November 10, 2014:  Want to see how to use UIActivityViewController in Swift?  Check out the my newer post Add sharing to your Swift app via UIActivityViewController [Read more…]

Filed Under: Class Reference

Using UILocalNotification

Last updated on August 6, 2014

Have you ever wanted to have your app give a notification when it is not open, but don’t have a web backend?  That’s where UILocalNotification comes in.

One caveat, UILocalNotification cannot open your app (at least as far as I know), so it can only run at pre-programmed times, but that is still useful in many situations.

An example use of UILocalNotification

UILocalNotification is pretty simple to setup in the simplest cases.  Below is an example of one I used:
[Read more…]

Filed Under: Class Reference

Introduction to UIColor

Last updated on January 20, 2016

For an app I am working on, I wanted to use some specific colors outside of the standard system ones.  Using UIColor is pretty easy, but I thought I would share with you how to use it in its simplest form, and a help category I made to make working with the built in functions a bit easier, and a tool I JUST found while working on this post that would have been very nice last week.  If you want to learn how to make a category, see my previous post Objective-C Categories.

Creating a UIColor Object

UIColor has several methods to generate a color based off of components.  The available ones are:

  • colorWithWhite:alpha:
  • colorWithHue:Saturation:brightness:alpha:
  • colorWithRed:green:blue:alpha:
  • colorWithCGColor:
  • colorWithPatternImage:
  • colorWithCIColor:

But we are going to work with colorWithRed:green:blue:alpha: in this post.

Also, each of those has an init form (so colorWithRed:green:blue:alpha: is initWithRed:green:blue:alpha: ).  This makes less difference in a post ARC world, but for reference, the initWith forms give your class ownership of the object, and so it must be released when you are done with it to avoid memory leaks.  The colorWith form (also called a “Factory Method”), does not give your class ownership, so it does not need to be released by your class, that is handled by the system.  Since ARC automatically counts your references, they are effectively the same for the programmer nowadays.

[Read more…]

Filed Under: Class Reference

Subscribe to the Coding Explorer Newsletter

* indicates required

Follow Us

Facebooktwitterrss

Recent Posts

  • Error Handling in Swift
  • Creating and Modifying a URL in your Swift App
  • Watch Connectivity in Swift — Application Context
  • watchOS Hello World App in Swift
  • API Availability Checking in Swift

Categories

  • Class Reference
  • General
  • Interface Builder
  • My Apps
  • Objective-C
  • Swift
  • Syntax
  • Tutorial
  • Uncategorized

Archives

  • May 2016
  • March 2016
  • February 2016
  • December 2015
  • July 2015
  • June 2015
  • April 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • January 2014
  • November 2013
  • September 2013
  • August 2013
  • July 2013
  • Terms Of Use
  • Privacy Policy
  • Affiliate Disclaimer

Subscribe to the Coding Explorer Newsletter

* indicates required

Copyright © 2025 Wayne Media LLC · Powered by Genesis Framework · WordPress