• Stars
    star
    897
  • Rank 50,907 (Top 2 %)
  • Language
    Objective-C
  • Created over 13 years ago
  • Updated over 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

iPhone Developer's Cookbook

Welcome to the source code repository for the iOS 5 edition of the iPhone Developer's Cookbook.

Sample code is never a fixed target. It continues to evolve as Apple updates its SDK and the CocoaTouch libraries.

Get involved. You can pitch in by suggesting bug fixes and corrections as well as by expanding the code that's on offer.

Github allows you to fork repositories and grow them with your own tweaks and features, and share those back to the main repository. If you come up with a new idea or approach, let us know. We'd be happy to include great suggestions both at the repository and in the next edition of this cookbook.

About the Cookbook

The iPhone Developer's Cookbook is written for experienced developers who want to build apps for the iPhone and iPod touch. It helps to be already be familiar with Objective-C, the Cocoa frameworks, and the Xcode Tools.

That said, if you're new to the platform, this edition of The iPhone Developer's Cookbook includes a quick-and-dirty introduction to Objective-C along with an intro to the Xcode Tools to help you quickly get up to speed.

Although each programmer brings different goals and experiences to the table, most iPhone developers end up solving similar tasks in their development work:

  • "How do I build a table?"
  • "How do I create a secure Keychain entry?"
  • "How do I search the Address Book?"
  • "How do I move between views?"
  • "How do I use Core Location and the iPhone 3GS's magnetometer?"
  • "How do I draw text around shapes?"
  • "How do I use a Page View controller?"

And so on. If you've asked yourself these questions, then this book is for you. The iPhone Developer's Cookbook will get you up to speed and working with the iPhone SDK, offering you ready-to-use solutions for the apps you're building today.

What's the deal with main.m?

For the sake of pedagogy, this book's sample code uses a single main.m file. This is not how people normally develop iPhone or Cocoa applications, or, honestly, how they should be developing them, but it provides a great way of presenting a single big idea. It's hard to tell a story when readers must look through five or seven or nine individual files at once. Offering a single file concentrates that story, allowing access to that idea in a single chunk.

These examples are not intended as standalone applications. They are there to demonstrate a single recipe and a single idea. One main.m file with a central presentation reveals the implementation story in one place. Readers can study these concentrated ideas and transfer them into normal application structures, using the standard file structure and layout. The presentation in this book does not produce code in a standard day-to-day best-practices approach. Instead, it reflects a pedagogy that offers concise solutions that you can incorporate back into your work as needed.

Contrast that to Apple's standard sample code, where you must comb through many files to build up a mental model of the concepts that are being demonstrated. Those examples are built as full applications, often doing tasks that are related to but not essential to what you need to solve. Finding just those relevant portions is a lot of work. The effort may outweigh any gains.

In this book, there are exceptions to this one-file-with-the-story rule: the cookbook provides standard class and header files when a class implementation is the recipe. Instead of highlighting a technique, some recipes offer these classes and categories (that is, extensions to a preexisting class rather than a new class). For those recipes, look for separate .m and .h files in addition to the skeletal main.m that encapsulates the rest of the story.

For the most part, the examples for this book use a single application identifier: com.sadun.helloworld. This book uses one identifier to avoid clogging up your iOS devices with dozens of examples at once. Each example replaces the previous one, ensuring that your home screen remains relatively uncluttered.

If you want to install several examples at once, simply edit the identifier, adding a unique suffix, such as com.sadun.helloworld.tableedits. You can also edit the custom display name to make the apps visually distinct. Your Team Provisioning Profile matches every application identifier, including com.sadun.helloworld. This allows you to install compiled code to devices without having to change the identifier; just make sure to update your signing identity in each project's build settings.

How to build these projects

You should be able to use your team provision to build and deploy these projects to the simulator or to devices. Before compiling, make sure you select a deployment target using the scheme pop-up menu at the top-left of the Xcode window.

For the most part, the samples for this book use a single application identifier, com.sadun.helloworld. This book uses one identifier to avoid clogging up your iPhone with dozens of samples at once. Each sample replaces the previous one, ensuring that SpringBoard remains relatively uncluttered. If you want to install several samples at once, simply edit the identifier, adding a unique suffix, such as com.sadun.helloworld.table-edits. You'll want to edit the display name so you can tell instantly which project is which. Samples use the same icons and launch images as well.

More Repositories

1

uidevice-extension

Add functionality to UIDevice to distinguish between platforms like iPod touch 1G and 2G and iPhone
Objective-C
1,525
star
2

NSDate-Extensions

Practical real-world dates
Objective-C
1,383
star
3

iphone-3.0-cookbook-

Sample Code
Objective-C
910
star
4

iOS-7-Cookbook

Objective-C
856
star
5

Auto-Layout-Demystified

Objective-C
545
star
6

iOS-6-Cookbook

iOS 6 update
Objective-C
460
star
7

iOS-6-Advanced-Cookbook

Recipes for working with the advanced features of iOS 6
Objective-C
380
star
8

ABContactHelper

Objective-C Address Book wrapper
Objective-C
284
star
9

uicolor-utilities

Helpful utilities for UIColor for iPhone
Objective-C
262
star
10

SwiftDates

Practical real-world dates: timey-wimey date-y things, Swift successor to old NSDate repo
Swift
225
star
11

iOS-Drawing

Objective-C
193
star
12

useful-things

Not to be confused with "needful things" (see King, Stephen)
Objective-C
142
star
13

now

Times around the world because no brain should have to work out what time it is in NYC or what time it is here when it's 4PM in London or what time 4PM in London is here...
Swift
139
star
14

Camera-Image-Helper

Live scanner images on demand
Objective-C
93
star
15

NSObject-Utility-Categories

Handy categories for Objective-C programming, including value-ready selectors and selector choices
Objective-C
87
star
16

swiftslowly

77
star
17

NSArray-Utilities

NSArray utilities
Objective-C
76
star
18

remind

Schedule a notification-center reminder from the command-line because sometime we just want to use tools already at hand to get on with the rest of our work.
Swift
68
star
19

tmdiff

Performs a command-line text diff on a file and its time machine ancestor
Swift
62
star
20

testlint

Objective-C
61
star
21

SwiftCookbook

The Swift Developer's Cookbook
Swift
57
star
22

iOS-Gourmet-Cookbook

Objective-C
51
star
23

xcopen

Because, yes, sometimes I really am so lazy that I want to cd and just open whatever xcproj is in the folder
Swift
45
star
24

SwiftString

Doing stuff with and to Swift strings
Swift
44
star
25

ibrowser

Please refer to the Chapter 13 samples instead. DEPRECATED Browse your normal (non-jailbroken) iPhone contents using a Web browser
Objective-C
41
star
26

SwiftUtility

Useful stuff!
Swift
37
star
27

SwiftGeometry

CGHeck
Swift
30
star
28

trash

Just because you're at the command line doesn't mean you can't use the safe Mac Trash.
Swift
30
star
29

datatube

Fixed-latency queues
Objective-C
30
star
30

Swift-Drawing

A chapter-by-chapter collection of playground-based source code that provides working examples of the material covered in Swift Drawing.
27
star
31

MPMediaItem-Properties

Category that adds properties to the media item directly (so you don't have to use valueForProperty: and can use directly with predicates)
Objective-C
27
star
32

App-Signer

AppleScript Utility for signing applications with dev or distro credentials
24
star
33

tmls

tmls - perform a time machine ls, preserving normal arguments
Swift
20
star
34

SwiftBezier

Assorted Bezier stuff
Swift
20
star
35

tmcp

Nondestructively copy flat time machine files to the working folder
Swift
20
star
36

TypeScript-xclangspec

A langspec-ish thing for Daniel
Shell
19
star
37

SwiftColors

Various useful color things. Swifty successor to old UIColor/NSColor repo.
Swift
17
star
38

SwiftPlaygrounds

Useful playground stuff
Swift
14
star
39

CFClippyRef

<shrill, eyes squinting> IT LOOKS LIKE YOU'RE WRITING A METHOD! Would you like me to open Windows Media Player for you?
Objective-C
14
star
40

Swift-General-Utility

General utility types and functionality
Swift
13
star
41

funpaths

UIBezierPaths
12
star
42

lns

Because no one can remember how to use `ln -s` when it really matters
Swift
11
star
43

SwiftCollections

SwiftCollections
Swift
10
star
44

AssetCatalog

Support for Asset Catalog JSON encoding and automated creation
Swift
10
star
45

Swift-Mac-Utility

Taking the Mac out of the General Utility and putting it in its own package
Swift
7
star
46

MatrixUtil

Handy 2D mathematical (x, y)-indexed access to flat backing arrays for Matrix-based grid work, including iteration, subarray access, and more.
Swift
7
star
47

SwiftFoundationAdditions

Swift
6
star
48

AnsiStyle

Simple Swift package to style terminal output
Swift
6
star
49

grid

Swift
5
star
50

fringe-tv-show-code-breaking

Help crack the Fringe commercial-break picture code
Shell
5
star
51

spmalot

Automate some chores for Swift Package Manager
Swift
5
star
52

SwiftInterpolation

Swift
5
star
53

d20

In which I take on watchOS and build something simple
Swift
5
star
54

Swift-Cmdline-Utility

Support utilities for command line development
Swift
4
star
55

SwiftDependencyExamples

Examples that vary by tag to demonstrate how to use SwiftPM to choose dependencies
4
star
56

Swift-Misc-Utility

Taking the misc out of General Utility so that General only defines the namespace.
Swift
4
star
57

AccessControlTestpad

Swift
3
star
58

show

Show and hide apps from the command line
Swift
3
star
59

AppleTVLinkOpener

Throw in a link to your app on the store to make it easier to hop over quickly
Swift
2
star
60

customsequences

Custom sequences built to support other projects. At this time, there is one sequence, the Cartesian.
Swift
1
star
61

package-name

Swift
1
star
62

SwiftNumbers

Swift
1
star
63

testrepo1

Swift
1
star