Kevin McNeish Blog

All things iOS, Kindle and .NET

Recent Posts

Tags

News

  • First books in my new book series, "iOS App Development for Non-Programmers" are now available! iBookStore: http://itunes.apple.com/us/book/book-1-diving-in-ios-app-development/id558788074?mt=11 Amazon: http://www.amazon.com/dp/B0097N8XBE Amazon: http://www.amazon.com/dp/B0099RQGMQ

Community

Email Notifications

Archives

Unleash Your Inne App Developer (Part 6) - The Big Picture

This week's post is now live on the iPhoneLife site:

 

http://www.iphonelife.com/blog/31369/unleash-your-inner-app-developer

 

 

In this week's post we dive into programming and discuss:

- The three parts of an app

- What is iOS

- Source Code, Compilers and Machine Code

- Understanding Classes and Objects

- Attributes, Properties & Methods

- Visual and Non-Visual Objects

 

 

All the best!

Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

 

Unleash Your Inner App Developer (Part 5 - Finishing the Prototype) is now live on the iPhoneLife Site

In this 5th post (includes step-by-step video) in my "Unleash Your Inner App Developer" blog series for iPhoneLife magazine, we finish building the prototype app!

http://www.iphonelife.com/blog/31369/unleash-your-inner-app-developer-finishing-prototype

All the best!

Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

Unleash Your Inner App Developer (Part 4) is live on the iPhoneLife site!

The fourth installment of my "Unleash Your Inner App Developer" blog series for iPhone Life magazine is now live, and includes a step-by-step video!

http://www.iphonelife.com/blog/31369/unleash-your-inner-app-developer-next-steps

 

All the best!

Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

Book 2: Flying with Objective-C now available in paperback!

Book 2: Flying with Objective-C is now available in paperback! This is one of the most comprehensive books on Objective-C that you will find!

http://www.amazon.com/Book-Flying-Objective-C-Development-Non-Programmers/dp/0988232715/ref=tmm_pap_title_0

The book includes links to instructional videos on our web site.

 

All the best!

Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

Unleash Your Inner App Developer - Adding Navigation (Part 3)

The next part in my blog series "Unleash Your Inner App Developer - Adding Navigation" is now live!

http://www.iphonelife.com/blog/31369/unleash-your-inner-app-developer-adding-navigation

All the best!

Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

Q&A: How do I fix the "Could not insert new outlet connection" error?

Whenever you see the dreaded "Could not insert new outlet connection. Could not find any information for the class named xx", it's almost always an Xcode problem. Even though the class named in the error message is in your project, Xcode loses track of it, and acts as if it's not there.

Assuming you have already tried restarting Xcode to fix the problem (you should try this first), here are a few solutions to this problem:

Remove the Class Files and Add Them Back in Again

  1. In the Project Navigator, select the .h and .m files of the class that Xcode is complaining about in the message.
  2. Press the delete key.
  3. When the confirmation dialog appears, choose the Remove References option.
  4. In the Project Navigator, right-click your project's main group and select Add Files to xx from the popup menu.
  5. Add the .h and .m class files back into the project.

Force Xcode to Rebuild the Project's Index

Xcode builds an index of all the files contained in the project. If this index has become corrupt, you can force Xcode to rebuild the index by following these steps:

  1. Open Xcode, but make sure the project is closed
  2. Click the Organizer button on the right side of the toolbar at the top of the Xcode window.
  3. In the Organizer window, click the Projects tab.
  4. On the left side of the Organizer window, select the project that has the problem.
  5. On the right side of the Organizer window, click the Delete button next to the Derived Data path.
  6. Reopen the project.

Hopefully one of these solutions works for you!

 

Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

 

Unleash Your Inner App Developer - Diving Deeper

My latest blog post for iPhone Life magazine includes step-by-step instructions and video for learning to build iOS Apps!

http://www.iphonelife.com/blog/31369/unleash-your-inner-app-developer-diving-deeper

 

All the best!

Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

 

Unleash Your Inner App Developer Part 3 - Step-by-step instructions for building your first iOS App!

 

The third installment of my blog series targets at non-programmers is now live on the iPhone Life web site! In this week's post we begin the process of creating an iOS app that accesses and stores data on the web, and integrates with the iOS camera, Facebook, Twitter, and much more.

http://www.iphonelife.com/blog/31369/unleash-your-inner-app-developer-getting-taste-app-development

All the best!

Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

 

Kick The Tires - Rent a Mac in the Cloud - Tools for Unleashing Your Inner App Developer

My second blog post in this series is now available on the iPhone Life web site!

http://www.iphonelife.com/blog/31369/how-unleash-your-inner-app-developer-getting-ready

All the best!

Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

 

"How to Unleash Your Inner App Developer" - My New Weekly Blog for iPhoneLife magazine!

All the best!

Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

Confessions of a Pizza Stalker

Well, this doesn't have anything to do with iOS, Android, or .NET, but, my wife Sharlene has a great new blog that's targeted at any of you pizza fanatics out there (and if you write code for a living, I KNOW you're out there)! Here it is:

http://www.pizzastalker.blogspot.com

We both attended the Pizza Expo 2013 in Las Vegas last week and it was a blast!

All the best!

Kevin McNeish

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

Q&A: How To Fix Xcode's "used as the name of the previous parameter" warning

 

When you upgrade to Xcode 4.6, you may find that you are getting a number of compiler warnings like this:

'xxxxx' used as the name of the previous parameter rather than as part of the selector

In this post I will show you why you're getting this warning, how to fix it, or how to ignore it.

Why You're Getting This Warning

This is typically caused by declaring a method without specifying a description of the parameter. For example, check out the following method declaration:

- (NSString *) getFormattedDateString:(NSDate *)date:(NSString *)formatString;

The intent of this code is to declare a method named getFormattedDateString that accepts two parameters named date and formatString.

Because there is no space between date and the colon (:), the compiler gives the warning "'date' used as the name of the previous parameter rather than as part of the selector".

How to Fix The Problem

There are two ways to solve this warning:

1. Put a space between date and the colon:

- (NSString *) getFormattedDateString:(NSDate *)date :(NSString *)formatString;

2. Add a description for the formatString parameter:

- (NSString *) getFormattedDateString:(NSDate *)date withFormat:(NSString *)formatString;

The second option is preferable because it makes your method more readable. That;s because parameter descriptions are part of the method signature. In this example, the method signature is:

getFormattedDateString:withFormat:

If you leave out the parameter description, the method signature is the less readable:

getFormattedDateString::

How to Ignore the Warning

Although it's preferable to fix these warnings by changing your method declarations, if you want to ignore them, you can simply add the following declaration to your project's PCH file (located in the Support Files group):

#pragma clang diagnostic ignored "-Wmissing-selector-name"

All the best!

Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

iPhoneLife Column and Blog

Hello All! Just wanted to let everyone know that I'm now a regular columnist and featured blogger for iPhoneLife magazine! I'll still be blogging here, but you can find more of my iOS content in the magazine and in my new blog:

http://www.iPhoneLife.com/blogs/kevin-mcneish

My first blog post is about Apple's expansion of the iBookStore into Japan and some new enhancements to iBooks and iTunes Producer.

 

All the best!
Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

Book 3: Navigating Xcode 4.6 now available on Amazon!

Great news! Book 3: Navigating Xcode 4.6 in our iOS App Development for Non-Programmers is now available on Amazon:

http://www.amazon.com/Book-Navigating-Development-Non-Programmers-ebook/dp/B00BLS8LRO/ref=sr_1_11?ie=UTF8&qid=1361977444&sr=8-11&keywords=xcode+4.6

This third book in the series helps you deliver high-quality Apps more quickly as it teaches you to take full advantage of all the great features in Xcode 4.6. 

Book 3 also includes information on:

  • Taking full advantage of the new user interface Auto Layout model
  • Thorough explanations and project samples on how to use all of the iOS user interface controls
  • Creating a well-designed App architecture that makes it easy to enhance and extend your Apps
  • Saving Data on an iOS Device with Core Data
  • In-depth coverage of using table views to manage lists of data
  • Saving Data on an iOS Device with Core Data
  • Managing Change with Refactoring
  • Moving Your Apps to iPhone 5 and iOS 6
  • And much more!

Includes Step-by-Step Instructional Videos!
Book 3 includes step-by-step instructional videos in which you watch the author perform each exercise in the book. This is great for non-programmers who might need some extra help. 

All the best!
Kevin McNeish 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

Maui, HI - iOS Apps for Non-Programmers Training Class, July 8-12, 2013

We have an additional location and dates for our iOS Apps for Non-Programmers Training Class (again, in addition to our April 1-5, 2013 Manhattan Beach, CA class). 
Maui Training Class Details
Our class will be held at the Maui Arts & Cultural Center, Maui, HI (2 miles from Maui's main airport). It's a five-day hands-on workshop that runs from July 8-12, 2013, 9am-5pm each day. This five day workshop, is specifically designed for non-programmers. It teaches you the skills you need to create great Apps for the iPhone and iPad, using the latest tools from Apple!
Beyond the Books
We ask that students go through Book 1 and most of Book 2 before attending class. That way we can go further than the book series currently does and cover topics such as:
  • Creating Universal Apps that work great on both the iPhone & iPad
  • Creating a well-designed App architecture
  • More Core Data - Saving data on a device 
  • Accessing data on the web
  • Creating a revenue stream with iAds
  • Interacting with the Camera
  • Integrating video and audio in your App
  • Interacting with other iOS Apps
  • Integrating iMessage, iCloud and Twitter
  • Integrating with iOS Passbook (creating event tickets, store cards, boarding passes, etc)
  • Working with Maps
  • Best practices in creating iOS Apps
  • And much more!
Bring Your Apps to Class!
We encourage students to bring the Apps they are working on to class. There is specific information we always cover in each class, but we find that learning about iOS technologies in the context of real-world Apps is the best way to understand how these features work, and how they can be used in your own Apps. 
We highly recommend The Old Wailuku Inn (just 2 miles from the MAAC center) as a great place to stay. You can also check out the Courtyard by Marriott Maui (just 2.5 miles from the MAAC center) in Kahului, HI, for a more typical hotel stay, or any other hotel of your choosing.
Early Bird Extended for our Manhattan Beach Class, April 1-5, 2013
We have had requests to extend our early bird special for our April 1-5, 2013 Manhattan Beach class, so we have extended the deadline until March 1, 2013.

For details on both classes, check out this link:
http://www.iosappsfornonprogrammers.com/Training.html
Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

Book 3: Navigating Xcode now available in the iBookstore!

Book 3: Navigating Xcode in our iOS App Development for Non-Programmer series  is officially released and available in the iBookstore today!

https://itunes.apple.com/us/book/book-3-navigating-xcode-4.5/id598559434?mt=11 

This book contains the most thorough coverage of Xcode that you will find! It is a deep dive into the tools and technologies of Xcode 4.5.

Book 3 also contains bonus information on:

- Taking advantage of the new user interface Auto Layout model in Xcode 4.5
- Moving Your Apps to iPhone 5 and iOS 6
- Thorough explanations and project samples on how to use all of the iOS user-interface controls
- Creating a well-designed App architecture that makes it easy to enhance and extend your Apps
- Working with Core Data
- In-depth coverage of using table views to manage lists of data
- Managing Change with Refactoring

Book 3 includes step-by-step instructional videos in which you watch the author perform each exercise in the book. This is great for non-programmers who might need some extra assistance.

 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

Macworld / iWorld Conference - See us release Book 3: Navigating Xcode!

It's official! We are releasing the latest book in our iOS App Development series, Book 3: Navigating Xcode at the Macworld  / iWorld conference in San Francisco this week.

Come visit us at Booth #413 at the expo. We will have some fun giveaways (including the new book) and would love to meet you face to face!

Best Regards,

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

We won! 2013 Publishing Innovation Awards - iOS App Development for Non Programmers

So, I'm pretty excited about this.

Today, at the Digital Book World Conference in NYC, it was announced that our book, iOS App Development for Non-Programmers, won the Publishing Innovation Award for best self-published book:

I'm particularly happy about this because we took the hight road and spent a LOT of time formatting the book for the iPad and the Kindle to take full advantage of each platform. We used full color, HD images, video, interactive diagrams, and so on. Congratulations to my wife Sharlene for the great photography in the book, which really helps it stand out. We have a great technical editor, Greg Lee, who helps make sure I'm covering all the bases, and an outstanding copy editor, Benjamin Miller who kept the book free from grammar, punctuation, inconsistencies, and anything else I threw at him!

This story has been picked up by many news organizations and on-line resources such as Apple Magazine: http://applemagazine.com/ios-app-development-for-non-programmers-earns-publishing-innovation-award/5334 

The third book in the series is all done but the final edits! More information on that as soon as it's ready!

We met some great authors with some outstanding books at the conference. I'll be sharing more about these in the weeks to come.

Kevin McNeish

 

Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

Hands-On iOS App Development Workshop - Manhattan Beach, CA - Apr 1-5, 2013

It's official. I'm teaching our next hands-on iOS App Development workshop at the Shade Hotel in Manhattan Beach, CA (a suburb of Los Angeles).

This workshop is a great place to dive into the world of iOS App development, and emerge with the skills to create your own Apps.

Check out our web site to learn more about this class:

http://www.iOSAppsForNonProgrammers.com/Training.html

 

Kevin McNeish
Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

 

 

Tutorial: Improving Your iOS App Architecture - Part 2 of 2

This tutorial is an excerpt from our book series iOS App Development for Non-Programmers, available in the iBookStore for the iPad, and on Amazon.

Part 1 of this post looks at a sample App with standard iOS architecture and points out the pitfalls you need to avoid. Part 2 of this post demonstrates the same sample App with an improved architecture that helps make the App easier to design, create and maintain.

In Part 1 of this post, we learned that the iOS view controller is a user interface object that is tightly bound to the user interface. This is not a problem. The problem occurs when core logic is placed in the view controller because it prevents the code from being reused and extended as your App goes through its normal change life cycle.

So, how do you fix this problem? You need to put the Calculator’s core logic in some other place where you can access it from multiple Apps, or from multiple view controllers in a single App. If you shouldn’t put your core logic in a view controller, where should you put it? 

Business Controller Objects

The answer is, a business controller object (also known as a business object or domain object). If you have read Book 2: Flying with Objective-C, you have already seen business objects at work—for that matter, you have even seen a Calculator business object.

A business object provides a neutral place to put your core logic that can be reused from any user interface, which includes view controllers. As shown in Figure 11.24, you can create a Calculator business object in which you put all of the Calculator’s core logic methods.

Figure 11.24 Implementing a Calculator business object

In this figure, the Calculator and View Controller are tightly bound together—and that’s OK—they are both user-interface objects. When buttons are tapped on the calculator at run time, action methods in the view controller are called directly. 

The only code you should put in the view controller is code that has something to do with the user interface. However, when core logic needs to be performed, the view controller makes a call to an appropriate method in the Calculator business object.

With your core logic in the Calculator class, you can easily create a ScientificCalculator subclass, which inherits all the basic functionality of the Calculator and extends it by adding additional operations as shown in Figure 11.25.

Figure 11.25 You can easily extend the core logic of the Calculator when it resides in its own class.

Because you have elevated your core logic out of the user interface and into a Calculator business object, it makes it far easier to extend by creating a subclass.

Other Benefits of Using Business Objects

When you create business objects, you are creating a representation of objects in the real world. In the Calculator App, you are creating a representation of a real-world calculator. In a real estate App you can create House, Buyer, Owner, and RealEstateAgent business classes that represent real-world entities (Figure 11.26).


Figure 11.26 Business objects represent real world entities.

Creating business objects help you bridge something called the semantic gap. The semantic gap is the difference between real world entities and how you model, or describe these objects in your software applications. In many Apps, this gap is extremely wide because the developer has not created any business objects. You will find that when you narrow the semantic gap by creating business objects that represent real-world entities, your Apps are much easier to conceive, design, build, maintain, and extend. 

You model real-world entity attributes by means of properties, and you model their behavior by means of methods. For example, a house has attributes such address, number of bedrooms, number of baths, price, and so on which can be described, or modeled, as properties. A house also has behavior such as “put on the market,” “take off the market,” and so on which can be modeled as methods on a business object class.

Another benefit of using business objects is it helps you avoid playing the game of “where’s the code?” When your core-logic code is raised out of the weeds of the user interface and into business objects, it’s far easier to find the code you want. 

For example, all the core-logic code that has something to do with a homeowner is in the HomeOwner business object. All the code that has something to do with a real-estate agent is in the RealEstateAgent project, and all the code that has something to do with the user interface is in a view controller. When your code is segregated in this way, it makes it far easier to find the code you need.

In contrast, when your core logic code is tangled up in your user interface, it’s much harder to find the code you need. You can see a great example of this in the CalculatorDemo project. 

If you haven't already downloaded the sample code from part 1 of this blog post, you can download it here:

Download Sample Code

  1. If it’s not already open, in Xcode, open the CalculatorDemo project again.

  2. In the Navigator panel on the left side of the Xcode window, select the Symbol Navigator by clicking the second button from the left in the Navigator toolbar, or by pressing Command+2
  3. As shown in Figure 11.27, there are only two classes in the project—AppDelegate and ViewController

    Figure 11.27 CalculatorDemo project classes

  4. Expand the ViewController node to view all of its members. As you can see, there are many methods in the class, some user interface related, and some containing core logic. This mix of methods can make it difficult to find the code you need.

In the next section, you will compare an improved Calculator sample project in the Symbol Navigator.

And one other thing—using business objects helps you avoid code redundancy. When you don’t use business objects, it’s easy to create duplicate code, because you often forget you have already created a piece of functionality in another view controller. When you are using business objects, it’s less likely you will create two methods on the same business object that perform the exact same function.

So, elevate your code, and use business objects.

Now let’s see how a Calculator business object can help in an improved Calculator sample App.

The Improved Calculator Sample App

To see this proper division of user interface and core logic, let’s check out another sample project for this chapter.

  1. In Xcode, open the CalculatorPlusDemo project located in this book’s sample code.

  2. Press the Run button in Xcode to run the project in the Simulator. Go ahead and test it out by performing calculations. As you can see, it works just like the CalculatorDemo App. 

  3. When you’re done, go back to Xcode, and press the Stop button.

  4. In the Project Navigator, drill down into the CalculatorPlusDemo node and then expand the User Interface and Core Logic groups. As you can see in Figure 11.28, under the User Interface group are the storyboard and view-controller user-interface files. Under the Core Logic group are the Calculator business-object class files.
  5. Figure 11.28 CalculatorPlusDemo project files

  6. Select the Symbol Navigator by clicking the second button from the left in the Navigator toolbar, or by pressing Command+2. Expand the Calculator and ViewController nodes to see their class members. As shown in Figure 11.29 (the Symbol Navigator is split in two to make it easier to view), there is a clear division of responsibilities between the Calculator class and the ViewController class.
  7. Figure 11.29 CalculatorPlusDemo project classes

  8. Let’s take a closer look at the source code for these classes. Go back to the Project Navigator by clicking the first button on the left in the Navigator toolbar, or by typing Command+1. Select the ViewController.h header file in the Project Navigator. As we look through the code in this class, remember that a view controller is a user-interface class.

  9. The first thing to take note of is that the Operation enumeration that was declared in the view controller in the CalculatorDemo project is missing. This is appropriate because it has nothing to do with the user interface.

    Take a look at the list of properties in the file:

    @property (strong, nonatomic) Calculator *calculator;

    @property (weak, nonatomic) IBOutlet UILabel *lblTotal;

    @property (strong, nonatomic) IBOutletCollection(UIImageView) NSArray *operationHighlightImages;

    Notice that the value property that was in the CalculatorDemo project’s view controller is missing. Again, this is appropriate, because it has nothing to do with the user interface—it contains the current value of the Calculator.

    Take note of the new Calculator property. This property holds a reference to the Calculator business object. This allows any method in the view controller to easily access the Calculator object and call its methods.

  10. Look below the property declarations to see the public method declarations:

    - (IBAction)highlightOperation:(UIButton *) sender;
    - (IBAction)numberTouched:(UIButton *) sender;
    - (IBAction)operationTouched:(UIButton *) sender;

    These are the same public action methods as found in the CalculatorDemo project. This is appropriate because these are all user-interface-specific methods that are tied to user-interface controls in the view.

  11. Go back to the Project Navigator and select the ViewController.m implementation file. At the top of the code file, check out the viewDidLoad method:

    - (void)viewDidLoad
    {
        [super viewDidLoad];

        // Create the calculator
         self.calculator = [[Calculator alloc] init];
    }

    This code creates an instance of the Calculator class and stores a reference to the object in the calculator property.

  12. Let’s contrast the message flow of the improved CalculatorPlusDemo App with the CalculatorDemo App. Figure 11.30 provides a high-level overview of what happens when a user touches a numeric button in the improved CalculatorPlusDemo App.


  13. Figure 11.30 Calculator numeric button and code interaction—the improved model

    1.  The user touches a numeric button.

    2. The numberTouched: action method in the view controller is called, which contains user-interface-specific code.

    3. After executing the user-interface processing, the view controller calls the Calculator object’s processNumber: method.

    4. The Calculator object’s processNumber: method executes the core logic for handling a new number and returns the Calculator’s current value.

    5. The view controller takes the value returned from the Calculator’s processNumber: method and stores it in the text property of the lblTotal label.

    This is very similar to the high-level overview in Figure 11.21, except the processNumber: method has been moved from the ViewController class to the Calculator class.

  14. Now let’s look at a high-level overview of what happens when the user touches an operation button as shown in Figure 11.31

    .

    Figure 11.31 Calculator operation button and code interaction—the improved model

    1. The user touches an operation button.

    2. The operationTouched: action method in the view controller is called, which contains user-interface-specific code.

    3. After executing the user-interface processing, the view controller calls the Calculator object’s performOperation: method.

    4. The Calculator object’s performOperation: method executes the core-operation logic and returns the Calculator’s current value.

    5. The view controller takes the value returned from the Calculator’s performOperation: method and stores it in the text property of the lblTotal label.

    Again, this is very similar to the high-level overview in Figure 11.22, except the processOperation method has been moved from the ViewController class to the Calculator class.

Although this simple App has just one business controller object referenced from a single view controller, more complex Apps may reference several business objects. For example, Figure 11.32 shows a view controller that references four different business controller objects.

Figure 11.32 A single view controller can reference multiple business objects.

You can add properties to the View Controller that reference the business controller objects just as the ViewController class references the Calculator object in the CalculatorPlusDemo project.

Business Objects are User Interface Agnostic

Before moving on, it’s important to note that the business object knows nothing about the user interface in which it’s being used. Within the business-object properties and methods there is no reference at all to any user-interface element. This means you can reuse this business object from any view controller in the App, from a completely different iOS App, or, for that matter, you could even use it in a Mac OSX desktop application!

Business Objects and the MVC Pattern

When it comes to the Model-View-Controller (MVC) design pattern, you have learned the View and View Controller comprise your user interface, and together, are the View in the MVC pattern.

You have also learned that your App’s core logic should be contained in business objects that represent real-world entities. These business objects are the Controller in the MVC pattern.

But what about the Model? Earlier in this chapter you learned that the Model is your App’s data and usually takes the form of business entities.

In Chapter 12: Working with Core Data, you are going to learn about an iOS technology known as Core Data that uses something called entity objects. These entity objects are part of the business-object picture—half of the picture to be precise. Entity objects contain attributes that describe real-world entities. Business controllers are the other half of the business object picture. They are used to model the behavior of a real-world entity as you saw with the Calculator and ScientificCalculator classes in Figure 11.25.

Figure 11.33 completes the picture and shows you how each of these pieces fit into the Model-View-Controller design pattern.

Figure 11.33 Each piece of the architecture fits into the MVC design pattern.

  • Model – The business entity is the Model in the MVC pattern. The properties of the business entity contain information that comprises the App’s data.

  • View – Both the View and the View Controller are user-interface objects and are therefore the View in MVC. All user-interface-specific code goes in the view controller.

  • Controller – The business-object controller is the Controller in the MVC pattern. All core logic goes into the business-object controller.

For each business entity you create for your App, you can create an associated business controller. For example, in Figure 11.34, for every business entity, there is a corresponding business object. The CustomerEntity class has a Customer business object, the ShoppingCartEntity class has a ShoppingCart business object, and so on.

Figure 11.34 For each business entity in your App, you can create a corresponding business controller.

As already mentioned, the entity class models a real-world entity’s attributes by means of properties. The associated business-controller object models its behavior by means of methods. 

Business controllers can also be used to retrieve and update entity objects. Unfortunately, Apple’s default core-data model places the business entity retrieval and update code in the view controller. As you might imagine, this is a bad design, because it ties your App’s data access to the user interface. Placing your App’s data access logic in the business controller allows you to use your business controller objects from any user interface. You will learn more about this in Chapter 12: Working with Core Data.

Kevin McNeish
Author: iOS App Development for Non-Programmers book series 
Twitter: @kjmcneish

 

 

 

More Posts Next page »