Coding Explorer Blog

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

  • Home
  • Apps
  • About
  • Contact

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

NSString – Objective-C Class Reference

Last updated on June 25, 2014

I have mentioned NSString in previous posts, so I might as well write about it in my new set of class reference posts.  I also keep forgetting the formatting specifiers, and so I’ll put up a table of those for everyone to see when you want to know the correct specifier for a formatted string.  As we’ve seen before, an NSString is an object that represents a block of text.  The name presumably comes from the fact that it is a string of characters, though that is just supposition, but does make it slightly easier to remember.  For a little history, in C, a string was an array of an 8-bit variable named “char”, which was short for character.  In each of those spots of an array was a number that would denote a letter based off of the ASCII standard.  If you’re curious, here is a link to a copy of the ASCII Table.  At the end of the string, to denote the end, was a NUL character, which is denoted by the number 0.  Unlike most of my trips into history though, this is actually still quite relevant to Objective-C.

[Read more…]

Filed Under: Class Reference

NSDictionary – Objective-C Class Reference

Last updated on June 25, 2014

Have you had a collection of objects that you want to by name?  Lets say you had an object that contains contact info for a person.  If I wanted to see the contact information for somebody, I’d want to just tell something, “Hey, give me Jimmy’s contact info”, and it would get it for me.  That is exactly what NSDictionary does for you.

NSDictionary is way to perform easy lookups for objects stored in the dictionary, via a key of some sort.  It basically stores data in something called a “key value pair”.  I will use the even simpler example of looking up the definition of a word in a standard Miriam-Webster style dictionary.  The word you are looking up is the “key.”  The definition you are trying to find for that word is the “value.”  In this post, I’ll go over some of the basics.

[Read more…]

Filed Under: Class Reference

  • « Previous Page
  • 1
  • 2

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