Posterous
Doron is using Posterous to post everything online. Shouldn't you?
Web_thumb
 
View Doron Katz's profile on LinkedIn

Apple’s New Stance On ‘Cookie Cutter’ Apps: Add More Features Or Perish

In the wake of Apple’s sudden decision to remove nearly all “sexy” applications from the App Store, we’ve been hearing that the company is also clamping down on so-called “cookie-cutter” applications — iPhone apps that are built from templates using one of the many app-building services available. This would be yet another major change for the App Store, as it already features thousands of such applications. And, perhaps more important, quite a few companies have sprung up to facilitate building iPhone applications. I’ve reached out to Apple to ask if they’d like to clarify their stance, but given their lack of transparency in the past, I’m not betting on getting anything definitive. To try to get to the bottom of the current situation, I spoke with multiple developers (some of whom wished to remain anonymous) to find out what Apple was telling them.

Between the developers I spoke to, the consensus was this: Apple doesn’t appear to be opposed to ‘app generators’ and templates per se, but in the last month or so it has started cracking down on basic applications that are little more than RSS feeds or glorified business cards. In short, Apple doesn’t want people using native applications for things that a basic web app could accomplish. For some of these services that’s bad news, because that’s exactly the sort of application they produce; any new applications they submit are going to get rejected. But all hope isn’t lost for them, provided they can make their apps more useful.

Unlike the ’sexy’ app ban that took place a few weeks ago, when Apple gave developers no options to keep their apps on the store, over the last month the company has been reaching out to at least a few app building services to suggest what they should be doing.

The founders of Appmakr

, which has been used by publications like The Atlantic

to build iPhone applications, say that the process has been quite positive (though they are quick to clarify that applications built with their tools are more full-featured than the basic RSS apps described above). After some suggestions from Apple, the service is integrating new features like in-app purchases, instant notifications, offline access, and landscape viewing modes to their app templates. Another developer mentioned that they might include a tip calculator for restaurant apps. Appmakr’s hope (and one that I’m sure is shared by other developers) is that applications generated using their tools will eventually be given an accelerated path through the App Store’s approval process, because Apple is familiar and happy with the kind of apps they produce.

However, from what I’ve gathered not everyone is having as much luck as the Appmakr team. Multiple developers mentioned that they’d heard of some app vendors that Apple wasn’t being nearly as accommodating towards — I suspect services offering the most basic templates are getting hit hardest. That said, the developers I spoke to said that they’d only heard about Apple blocking newly submitted applications, and that there wasn’t an indication that Apple is going back and removing all of the overly-basic apps they can find.

So why is Apple doing this? Here’s what Medialets

CEO Eric Litman had to say, which I think perfectly summarizes the situation.

This is the ongoing balance point between encouraging innovation and growth on one side and wanting to tightly control user experience on the other. Apple wants iPhone apps to be superior to Web experiences because they are extremely sticky and drive people specifically to buy the iPhone over competing smartphone platforms. Apps that are too simple or largely indistinguishable from the Web, other apps or particularly other apps on other platforms send the message to end users that the iPhone app ecosystem might not be particularly special.

Now the challenge for Apple is that the app building platforms are extremely attractive to a wide swath of the market that would otherwise be reluctant to bear the cost and complexity of developing an app from scratch. We have already seen apps from personal bloggers up to major media brands using some of these platforms, and many of the folks in that spectrum have content Apple would certainly want in the App Store. Interestingly, some of those same developers also have fully custom-built apps in the App Store, too.

So what are the platforms to do about the recent crackdown from Apple? There’s really only one choice if they want to continue to exist on the iPhone: invest in building out considerably more flexibility into their platforms to allow each app to differ from the others they build. Integrate more features and take the time to nail the design and UI elements to be representative of what Apple wants to see in every app.

For better or worse, Apple will be looking more closely at apps from the platforms than from individual developers. AppLoop, the first startup to announce and iPhone-specific app builder, is already gone. Others will almost certainly follow.

Overall, this will almost certainly result in a better experience for users as they have to deal with fewer spammy apps. But, as I wrote when Apple launched its war on sex apps last month, the policy change may also scare developers. After effectively sending a message to developers that basic applications were okay, Apple is again changing its mind.  Some developers may be hesitant to build their businesses around the iPhone, knowing that at any moment Apple could change its mind and cut off their only mode of distribution.

Thanks to Robert Strojan

for the tip
Photo by Goosmurf

Information provided by CrunchBase

Filed under: iPhone Dev

Objective-C Open source libraries

Libraries:

1. Three20

Three20 is a collection of iPhone UI classes, like a photo viewer, and general utilities, like an HTTP disk cache. Here is the list of components available in Three20

Photo Viewer

TTPhotoViewController emulates Apple’s Photos app with all of its flick ‘n pinch delight. You can supply your own “photo sources”, which works similiarly to the data sources used by UITableView. Unlike Apple’s Photos app, it isn’t limited to photos stored locally. Your photos can be loaded from the network, and long lists of photos can be loaded incrementally.

Message composer

TTMessageController emulates the message composer in Apple’s Mail app. You can customize it to send any kind of message you want. Include your own set of message fields, or use the standard “To:” and “Subject:”. Recipient names can be autocompleted from a data source that you provide.

Web image views

TTImageView makes it as easy to display an image as it is in HTML. Just supply the URL of the image, and TTImageView loads it and displays it efficiently. TTImageView also works with the HTTP cache described below to avoid hitting the network when possible.

Internet-aware table view controllers

TTTableViewController and TTTableViewDataSource help you to build tables which load their content from the Internet. Rather than just assuming you have all the data ready to go, like UITableView does by default, TTTableViewController lets you communicate when your data is loading, and when there is an error or nothing to display. It also helps you to add a “More” button to load the next page of data, and optionally supports reloading the data by shaking the device.

Better text fields

TTTextEditor is a UITextView which can grow in height automatically as you type. I use this for entering messages in Facebook Chat, and it behaves similarly to the editor in Apple’s SMS app.

TTPickerTextField is a type-ahead UITextField. As you type it searches a data source, and it adds bubbles into the flow of text when you choose a type-ahead option. I use this in TTMessageController for selecting the names of message recipients.

HTTP disk cache

TTURLRequest is a replacement for NSURLRequest which supports a disk cache (NSURLRequest can only cache in RAM). It has some other nice features too. HTTP posts are as easy as supplying a dictionary of parameters. The TTURL loading system can also be suspended and resumed at any time, which is a great performance helper. Network threads often fight with the UI thread, so you can suspend the network any time your app is momentarily graphically intensive.

URL-based Navigation

TTNavigationCenter is for those grizzled old web developers like myself who want to organize their app by “pages” which can be displayed by visiting a URL.

Your view controllers can simply register URL patterns that they handle, and when those URLs are visited the controllers will be created and displayed. You can also register generic actions that are called when a URL is visited.

TTNavigationCenter also persists and restores the full path of navigation controllers and modal view controllers, so your users can quite the app and come back exactly where they left off.

More details on:
http://github.com/facebook/three20

2. MajicRank 1.3

Here is a list of the features that this version, 1.3 adds:

* Adds historical graphs
* Stores all archives by AppID
* Reduces file size of stored archives
* Allows entering AppID with search preference over name
* Auto detects and fills in app ID when app name is entered
* Allows re-ordering of apps list
* Fixed a bug where deleting an app while editing it’s title caused a hang
* About box allows resizing, should now be viewable on low-res displays
* Adds latest date run to status text when update is complete

More details on:
http://148apps.biz/majicrank-13-released-adds-historical-graph/

3. Facebook connect Library for iPhone

* Seamlessly connect their Facebook account and information with your iPhone app
* Connect and share experiences with friends who also use your iPhone app
* Share user information and actions on your iPhone app with friends on Facebook

Details:
http://developers.facebook.com/connect.php?tab=iphonehttp://wiki.developers.facebook.com/index.php/Facebook_Connect_for_iPhone
http://wiki.developers.facebook.com/index.php/Facebook_Connect_for_iPhone

4. MGTwitterEngine ‚ Twitter from Cocoa

MGTwitterEngine is an Objective-C class which lets you integrate Twitter support into your Cocoa application, by making use of the Twitter API. The entire API is covered, and appropriate data is returned as simple native Cocoa objects (NSArrays, NSDictionarys, NSStrings, NSDates and so on), for very easy integration into your own application.

More details on:
http://mattgemmell.com/2008/02/22/mgtwitterengine-twitter-from-cocoa

5. Route Me

A slippy map library for the iPhone.

Fast! Completely written in objective-c using CoreAnimation. Runs like the built-in app.

More Details on:
http://code.google.com/p/route-me/

6. Core Plot

Core Plot is a plotting framework for Mac OS X and iPhone OS. It provides 2D visualization of data, and is tightly integrated with Apple technologies like Core Animation, Core Data, and Cocoa Bindings.

More details on:
http://code.google.com/p/core-plot/

7. RegexKitLite

This document introduces RegexKitLite for Mac OS X. RegexKitLite enables easy access to regular expressions by providing a number of additions to the standard Foundation NSString class. RegexKitLite acts as a bridge between the NSString class and the regular expression engine in the International Components for Unicode, or ICU, dynamic shared library that is shipped with Mac OS X.

* Uses the regular expression engine from the ICU library which is shipped with Mac OS X.
* Automatically caches compiled regular expressions.
* Uses direct access to a strings UTF-16 buffer if it is available.
* Caches the UTF-16 conversion that is required by the ICU library when direct access to a strings UTF-16 buffer is unavailable.
* Small size makes it ideal for use in iPhone applications.
* Multithreading safe.
* 64-bit support.
* Custom DTrace probe points.
* Support for Mac OS X 10.5 Garbage Collection.
* Uses Core Foundation for greater speed.
* Very easy to use, all functionality is provided by a category extension to the NSString class.
* Consists of two files, a header and the Objective-C source.
* Xcode 3 integrated documentation available.
* Distributed under the terms of the BSD License.

More details on:
http://regexkit.sourceforge.net/RegexKitLite/

8. CHDataStructures.framework

is an open-source library of standard data structures which can be used in any Objective-C program, for educational purposes or as a foundation for other data structures to build on. Data structures in this framework adopt Objective-C protocols that define the functionality of and API for interacting with any implementation thereof, regardless of its internals.

Apple’s extensive and flexible Cocoa frameworks include several collections classes that are highly optimized and amenable to many situations. However, sometimes an honest-to-goodness stack, queue, linked list, tree, etc. can greatly improve the clarity and comprehensibility of code. This framework provides Objective-C implementations of common data structures which are currently beyond the purview of Cocoa.

The abstract data type protocols include:

* CHDeque
* CHHeap
* CHLinkedList
* CHQueue
* CHSearchTree
* CHSortedSet
* CHStack

The concrete subclasses of NSMutableDictionary include:

* CHLockableDictionary
* CHOrderedDictionary
* CHSortedDictionary

The concrete subclasses of NSMutableSet include:

* CHLockableSet
* CHOrderedSet

The concrete subclasses of CHLockableObject (which don’t have a protocol) include:

* CHMultiDictionary

More Details on:
http://dysart.cs.byu.edu/CHDataStructures/

9.ResKit

A library for testing resolution-independent iPhone OS applications.

ResKit simulates varying device screen sizes by resizing and moving your application’s main window. It supports scaling down the simulated device so more of the screen can be seen at once.

Details:http://github.com/jtbandes/reskit/

10.Sintaxi/PhoneGap

PhoneGap is a development tool that allows web developers to take advantage of the core features in the iPhone, Android, BlackBerry, and Symbian with a unified JavaScript API

API

Device

Exposes properties of the phone, such as its device ID, model, and OS version number.

Location

Gain access to the Latitude / Longitude of the device, and depending on the type of device, the course, speed, and altitude.

Accelerometer

Monitor the accelerometer on the device to detect orientation, shaking and other similar actions.

Contacts

Query the phone addressbook to read the users contacts.

Orientation

Read the device layout orientation, e.g. landscape vs portrait.

Camera

Brings up the camera or photo browser on the phone to allow the user to upload a photo.

Vibrate

Triggers the vibration alert on the phone, if it is supported.

Sound

Play sound files (WAV, MP3, etc).

Telephony

Trigger and activate phone calls.

Details:http://github.com/sintaxi/phonegap/

11.Askit Framework
ASKit is an easy to use library for your iPhone applications. ASKit provides AppStore styled table views

ASKit Overview

  • ASTableViewController: Instead of subclassing UITableViewController, you’ll subclass ASTableViewController. This is where most of the work is done.
  • ASTableViewCell: This replaces UITableViewCell
  • ASHeaderView: Provides the gradient header that you can find when viewing a single app in AppStore
  • ASFooterView: This is the footer that AppStore shows your iTunes account in.
  • ASInfoCell This extends ASTableViewCell and should be used for various information messages such as “No Items” and “Loading” (it also contains an activity indicator for loading messages
  • ASSectionHeaderView: This is for table sections, you must return a view when using ASKit and not a string, otherwise it you won’t have the correct theme.
  • ASTableViewCellLabel: Use this instead of UILabel while adding to an ASTableViewCell so the shadows are handled correctly when a cell is selected

Details:http://github.com/enormego/askit/

12.ElementParser

ElementParser is lightweight Cocoa Framework (usable on the iPhone) to provide easy access to XML and HTML content.

Details:http://github.com/Objective3/ElementParser/

13.InAppSettingsKit

This iPhone framework allows settings to be in-app in addition to being in the Settings app

Details:http://github.com/futuretap/InAppSettingsKit/

14.Accelerometer-Helper

Accelerometer utilities for iPhone, including trigger sensitivity and time lockout between events

Details:http://github.com/ars/accelerometer-helper/

Hope it helps few, if not all of the aspiring iPhone developers.
The list will be updated as and when we encounter a new useful Open source library!
So keep Track.
Any addition to the list is Welcome!!

This article is credited to mobisoftinfotech.com

Filed under: iPhone Dev

Learning Objective-C by examples

For all of you Objective-C wanna-bies out there, if you prefer learning to program by example, this resource site will be your numero-uno bookmark!.  Appsamuck has 31 apps for you to look at the full source code, and see what you can implement!

Filed under: iPhone Dev

iPad Programming Tutorial – Hello World++

stariCodeBlog
3 February 2010 11:00 AM
by brandontreb

iPad Programming Tutorial – Hello World++

Introduction

Now, that the iPad has been released, I’m sure you are all scrambling for ideas on how to snag a piece of the maket in the imminent gold rush.  iCodeBlog is going to help you on your journey with a series of iPad tutorials to come.

Since the iPad uses the same SDK as the iPhone, all of the code under the hood is almost identical.  Actually, when looking at the new and changed API classes, you will realize that most of them are user interface related.  This is good news for us since we have already been coding iPhone.

While this tutorial is called “Hello World”, it is really much more than that.  I assume you already have working knowledge of iPhone/Objective-C programming.

What We Will Be Creating

In today’s tutorial, I will be showing you how to create an iPad project that uses the UISplitViewController to display content in 2 separate panes.  We will also be touching on some of the new design/UI patterns and giving an overall introduction to iPad programming.

The project will be based on one of my earliest tutorials that displayed a list of fruit in a UITableView and drilled down when they were selected.  We will be expanding on that example and creating something that will look like this.

It uses a UISplitViewController to display a UITableView on the left and a UIView with a UIImageView subview on the right.  This project is actually quite simple to create as the template code provides much of the code we need to get started.

Getting Started

1. Make sure you have downloaded the 3.2 SDK form http://developer.apple.com/iphone/.  The iPad simulator will come with this download.

2. Download the resources needed for this project and unzip them iPadHelloWorldResources.zip . (contains image files and a plist we will be using to load the images)

Creating The Project

Starting a project for the iPad is no different than starting one for the iPhone.  When you open XCode and select File->New Project, you should notice the addition of a Split View-Based Application.  Select this and name it iPadHelloWorld.

This will create a basic application with a UITableView on the left and a UIView on the right.  It will even populate the table with some sample elements.  It will add the following files to your project.

Here is a brief description of each of these files:

  • iPadHelloWorldAppDelegate – This is similar to every app delegate.  If you look in the application:didFinishLaunchingWithOptions method, you will see that the UISplitViewController is being allocated with the MasterViewController and DetailViewControllers.
  • MasterViewController – A UITableViewController, nothing fancy.  It will be handling the view on the left hand side.
  • DetailViewController – This handles the content view that you see on the right hand side.  We will be updating this as the user selects different rows in the table to the left.  This simply houses a single view.

Go ahead and press Build and Run to check out the application.  If you haven’t already done so, play around with the iPad contacts and settings apps as well.

Note: When you launch the application, you will only see the main view since the simulator runs in vertical mode.  To see the views side-by-side, rotate the simulator by clicking “Hardware -> Rotate Left/Right”.  You can also press CMD->Arrow Left/Right on the keyboard.

Importing The Project Images

Once you have had some time to play with the new iPad project, you will now need to import the images needed for this project.  After downloading and unzipping the files in from this tutorial, drag them into the project folder called “Resources-iPad”.

XCode will prompt you to copy the files, check yes and click OK.

Make sure you include all 4 images files as well as the file named fruits.plist.

Displaying The List Of Fruits

Displaying our fruits list is no different than displaying data in any other UITableView.  Let’s begin by opening MasterViewController.h and adding a declaration for our fruits array.

 


#import    @class DetailViewController;   
  @interface MasterViewController : UITableViewController 
  { DetailViewController *detailViewController; 
   NSArray * fruits; 
  }   
@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController; 
@property (nonatomic, retain) NSMutableArray *fruits;  
 @end


As you can see, there is nothing new here.  We simply declare our fruits array and create a property for it.

We will be loading the fruits from the plist file that you imported into your project in the last step.  Loading content from a plist file is a very quick and easy solution when you don’t require a database.

Open up MasterViewController.m and add the following line of code to your viewDidLoad method.

 
- (void)viewDidLoad { [super viewDidLoad]; self.fruits = 
  [[NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] 
  pathForResource:@"fruits" ofType:@"plist"]] retain]; 
}


The file fruits.plist is essentially an array that has been written out to a file.  If you open it up, it looks very similar to XML.  Now that our fruits array has been populated, let’s implement each of the UITableView delegate and datasource methods to populate the table.

UITableView datasource methods

- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section { 
// Return the number of rows in the section. 
return [fruits count]; 
}   
- (UITableViewCell *)tableView:(UITableView *)tableView 
   cellForRowAtIndexPath:(NSIndexPath *)indexPath {   
       static NSString *CellIdentifier = @"CellIdentifier";   	
           // Dequeue or create a cell of the appropriate type. 	
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
          reuseIdentifier:CellIdentifier] autorelease]; 
cell.accessoryType = UITableViewCellAccessoryNone; 
}   
// Get the object to display and set the value in the cell. 
cell.textLabel.text = [self.fruits objectAtIndex:indexPath.row]; 
return cell; 
}

 

Nothing special… We first tell the tableview that we want fruits.count (4 in this case) number of rows.

Next, we display the name of the fruit in each tableview cell.  If you want to learn more on UITableViews, read this tutorial.

UITableView delegate methods

[code lang=’c’]
- (void)tableView:(UITableView *)aTableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
/* When a row is selected, set the detail view controller's detail
item to the item associated with the selected row. */
detailViewController.detailItem = [self.fruits objectAtIndex: indexPath.row];
}
[/code]


 

Here, we are simply setting the detailItem property of the detailViewController to the selected fruit.  We will discuss this property later in this section, but for now all you need to know is that its type is id.

At this point, go ahead and press Build and Run to see your code in action.  You should see something that looks like this:

It displays the list of fruits, but nothing happens when you select a cell (well the title of the detailView may change).

Now that we have our list of fruits displayed, we now need to implement the code to display their corresponding image.

Displaying The Fruits

Displaying the selected fruit is actually quite simple.  The first thing we need to do is add a UIImageView to our detailView.

Start by adding the IBOutlet for the image view.  Open up DetailViewController.h and add the following code:

@interface DetailViewController : UIViewController {   
UIPopoverController *popoverController; 
UINavigationBar *navigationBar;   id detailItem;   
IBOutlet UIImageView * fruitImageView; 
}   
@property (nonatomic, retain) UIPopoverController *popoverController; 
@property (nonatomic, retain) IBOutlet UINavigationBar *navigationBar;   
@property (nonatomic, retain) id detailItem;   
@property (nonatomic, retain) IBOutlet UIImageView * fruitImageView;   
@end


 

All of the code here comes with the template except the code to add the IBOutlet UIImageView.  Once you have added this open up DetailView.xib in interface builder.

Add a UIImageView on to the view and size it to 500×500.

Now, click on the File’s Owner object and open the connection inspector (Tools -> connection inspector).

Drag from your imageView IBOutlet to the UIImageView and release.  The UIImageView is now connected to your outlet.

Note: If you want the images to not skew, set the content mode of the image view (in the attributes inspector) to Aspect Fit.

Now that the imageview has been connected, it’s time to write the code that updates it.  Close Interface Builder and open the file DetailViewController.m and add the following lines to the setDetailItem method:

- (void)setDetailItem:(id)newDetailItem { 
if (detailItem != newDetailItem) { 
  [detailItem release]; detailItem = [newDetailItem retain];   // Update the view. 
navigationBar.topItem.title = detailItem; 	
NSString * imageName = [NSString stringWithFormat:@"%@.png",detailItem]; 	
[self.fruitImageView setImage:[UIImage imageNamed:imageName]]; }   
if (popoverController != nil) { 
	[popoverController dismissPopoverAnimated:YES]; 
} 
}


Most of this code has been added by the template and I won’t discuss it too much in this tutorial.  But for now, the important additions are the lines that load the image based on  the name of the fruit and the one below it that sets the image property of the image view.

There you have it! Build and go and the application should function as mentioned.  Here is another screenshot of the final product.

Another Cool Feature Of SplitViewController

When in vertical mode, the SplitViewController gives you another new UI element called the UIPopOverView.  Collin will have a tutorial up soon on this view, but the figure below shows you what I’m talking about.

When the device is vertical, it will automatically rotate your view and provide a UIPopoverView when the “Master List” button is pretty. (BTW this button is also customizable).

You may download the source for this tutorial here iPadHelloWorld.zip.

If you have questions, post them here or ask me on Twitter.

Happy iCoding!

iPad Programming Tutorials ipad ipad coding ipad programming
Filed under: iPhone Dev

How To Use UIScrollView in Your iPhone App

Implementing UIScrollView in Cocoa-Touch

This example starts with a View Based Application with the image already in the Resources group. You can create this yourself using XCode’s “New Project” menu item.

Add IBOutlets

Select the view controller interface file and add the scroll view IBOutlet and the image view property:

	#import <UIKit/UIKit.h>

	@interface UseScrollViewViewController : UIViewController {
		IBOutlet UIScrollView *scrollView;
		UIImageView *imageView;
	}

	@property (nonatomic, retain) UIScrollView *scrollView;
	@property (nonatomic, retain) UIImageView *imageView;

	@end

Finish implementing the IBOutlet and property in the implementation file.

	#import "UseScrollViewViewController.h"

	@implementation UseScrollViewViewController
	@synthesize scrollView, imageView;

	- (void)dealloc {
		[super dealloc];
		[imageView release];
		[scrollView release];
	}

	@end

Adopt the Delegate Protocol

To use UIScrollView we must adopt the UIScrollViewDelegate protocol. Once we do our view controller may act on behalf of our scroll view. Simple add this after the UIViewController sublcass: <UIScrollViewDelegate&gt.

	#import <UIKit/UIKit.h>

	@interface UseScrollViewViewController : UIViewController
<UIScrollViewDelegate> {
		IBOutlet UIScrollView *scrollView;
		UIImageView *imageView;
	}

	@property (nonatomic, retain) UIScrollView *scrollView;
	@property (nonatomic, retain) UIImageView *imageView;

	@end

Implement the Delegate Method viewForZoomingInScrollView

Implementing this method will allow the scroll view to provide the pinching and zooming behavior demonstrated in the video.

	#import "UseScrollViewViewController.h"
	@implementation UseScrollViewViewController

...

	- (UIView *)viewForZoomingInScrollView:(UIScrollView *)
       scrollView{
		return imageView;
	}

...

	@end

Create the Image View

The image view will be used to display the image on the view. This is pretty straightforward: you will simple create the object and set it to the property we defined earlier in the viewDidLoad method.

	- (void)viewDidLoad {
	    [super viewDidLoad];
		UIImageView *tempImageView = [[UIImageView alloc] 
                initWithImage:[UIImage imageNamed:@"Beer-Sign-On-Wall.jpg"]];
		self.imageView = tempImageView;
		[tempImageView release];

	}

Set the UIScrollView Properties

Since we are using Interface Builder to add the scroll view we do not need to create it here. But, we will be setting some of the scroll view properties. Note that we add the image view to the scroll view’s subview collection.

	- (void)viewDidLoad {

...

		scrollView.contentSize = CGSizeMake
          (imageView.frame.size.width, imageView.frame.size.height);
		scrollView.maximumZoomScale = 4.0;
		scrollView.minimumZoomScale = 0.75;
		scrollView.clipsToBounds = YES;
		scrollView.delegate = self;
		[scrollView addSubview:imageView];
	}

Add Scroll View in Interface Builder

Now all you need to do is add your scroll view in interface builder and hook it up to the IBOutlet you defined in the view controller!

A good article on UIScrollView

Filed under: iPhone Dev

Acrobat.com now on iPhone

Mark Szulc has reported in his personal blog that acrobat.com, an Adobe press release statement that announced Acrobat.com is now available for the iPhone. Acrobat.com is an Adobe collaboration package that allows for a user to work with, and create PDFs, and print and share PDFs, as well as fax PDFs directly from your phone. So you can take a photo of a whiteboard (as Mark says) and share it as a pdf with your buddies on the other side of the world. 

   
Click here to download:
Acrobat.com_now_on_iPhone.zip (30 KB)

How To Add A Nice Background Image To Your Grouped Table View

 

Are you tired of your table views having the standard, boring, gray and white striped background?

Adding a nice image or pattern to your table views is one way of putting a little extra gloss to your UI. 

This is important, because gloss sells…

However, if you have tried to do this yourself you already know that simply inserting an image into your table view will produce ugly artifacts.

 

THE WRONG WAY

 



//This method produces odd artifacts in the background image: 


ATableViewController *yourTableViewController = [[ATableViewController alloc] initWithStyle:UITableViewStyleGrouped]; 


yourTableViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TableViewBackground.png"]]; 


[window addSubview:yourTableViewController.view];


[window makeKeyandVisible];


 

And here is what my Tasting Notes background looks like when I 

simply add an image to the table view’s backgroundColor property:

 

 

THE RIGHT WAY

What you need to do is create a view with your background image and add that view to your app’s window. Then you must set the table view’s 

background color to “clearColor”. Here is how you would do that from the app delegate:

 

UIView *backgroundView = [[UIView alloc] initWithFrame: window.frame];
backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TableViewBackground.png"]];
[window addSubview:backgroundView];
[backgroundView release];



yourTableViewController = [[ATableViewController alloc] initWithStyle:UITableViewStyleGrouped];
yourTableViewController.view.backgroundColor = [UIColor clearColor];
[window addSubview:yourTableViewController.view];

[window makeKeyAndVisible];


 

'yourTableViewController' is declared at the top level of the app delegate andATableViewController is a subclass of UITableViewController that simply displays the rows

 and sections in the example. Using the code above produces this cleaner image in the background:

 

Adapted from the article by MATTJDRAKE on MARCH 19, 2009 (howtomakeiphoneapps.com)

 

Filed under: iPhone Dev

Objective-C: NSNotification: an alternative to delegation

NSNotification: an alternative to delegation

12 Sep 2009

 

Sometimes, delegation is not sufficient to a task. This will occur when you need to notify multiple objects of an event. The only way to do that using delegation is to have an array of delegates, and then send the message to each one. In this case, though, NSNotification is a much better choice.

 

In the header file to the class that wants to post notifications (in this case, JSAutoWibbler), you must prototype the NSString identifiers of each notification type:



extern NSString * const JSAutoWibblerDidWobbleNotification;


extern NSString * const JSAutoWibblerDidWeebleNotification;


Then, in the implementation file, define those identifiers:



NSString * const JSAutoWibblerDidWobbleNotification


  = @"JSAutoWibblerDidWobbleNotification";


NSString * const JSAutoWibblerDidWeebleNotification


  = @"JSAutoWibblerDidWeebleNotification";


Now, you are prepared to post those notifications. Whenever your JSAutoWibbler wobbles, you can use message to the shared instance of NSNotificationCenter:



[[NSNotificationCenter defaultCenter] 


  postNotificationName:JSAutoWibblerDidWobbleNotification


                                                    object:self];


or, if you need to send more information along with the notification, package it in an NSDictionary and send it as the userInfo parameter:



[[NSNotificationCenter defaultCenter] 


  postNotificationName:


  JSAutoWibblerDidWobbleNotification


                                                    object:self


                                                  userInfo:dict];


When you have an object that you want to watch for notifications:



[[NSNotificationCenter defaultCenter] addObserver:self


               selector:@selector(didWobble:)


              name:JSAutoWibblerDidWobbleNotification


              object:someWibbler];


The signature of any notification handlers must be in the form - (void)notificationHandlerName:(NSNotification *);; thus, didWobble: would be declared like this:



- (void)didWobble:(NSNotification *)notification;


I like to keep my notification handlers in a private category, because they should never be called outside the class in which they are implemented.

 

Finally, you need to remove yourself as an observer. In dealloc, do the following:



[[NSNotificationCenter defaultCenter] removeObserver:self];


 

Now, get coding!

Taking on another article by Jonathan Sterling on the merits of NSNotification

Filed under: iPhone Dev

Objective-C: Another article on Using custom delegates

Using custom delegates in Objective-C

01 Aug 2009

 

On Stack Overflow there has been some interest in how to use the Delegate design pattern in Objective-C. Of course, the first step in any search should be to read Apple’s documentation, but many people seem not to want to read the whole thing. Trust me, folks, it is worth it. But Apple’s documentation on creating delegates doesn’t use protocols, which are such an amazing and useful part of the Objective-C language.

 

That being said, I’d like to give a short demonstration of how to create a class with a delegate. For the purposes of this tutorial, we’ll call our class JSTutorial.

The interface to JSTutorial starts out as the following:



@interface JSTutorial: NSObject {


  NSString *title;


  NSString *body;


}


- (void)generateTutorial;


@property (nonatomic, retain) NSString *title;


@property (nonatomic, retain) NSString *body;


 


@end


 

Now, we need to modify this interface to include a delegate protocol:

 



@class JSTutorial;


@protocol JSTutorialDelegate <NSObject>


@optional


- (void)tutorialDidFinish:(JSTutorial *)tutorial;


@end


 


@interface JSTutorial: NSObject {


  NSString *title;


  NSString *body;


  id <JSTutorialDelegate> delegate;


}


 


- (void)generateTutorial;


@property (nonatomic, retain) NSString *title;


@property (nonatomic, retain) NSString *body;


@property (nonatomic, assign) id <JSTutorialDelegate> delegate;


 


@end


 

The implementation for JSTutorial might look like this:

 



@implementation JSTutorial


@synthesize title;


@synthesize body;


@synthesize delegate;


 


- (void)generateTutorial {


  // do something here?


  [[self delegate] tutorialDidFinish:self];


}


 


- (void)dealloc {


  [title release];


  [body release];


  [super dealloc];


}


 


@end


 

Finally, the class that implements JSTutorialDelegate might have its interface declared as follows:

 



 


@interface SomeClass : SomeControllerClass <JSTutorialDelegate>


...


@end


SomeClass should implement tutorialDidFinish:, but it is optional.

I hope that this has helped those who were struggling with the delegate design pattern.

 

 

An article by Jonathan Sterling

Filed under: iPhone Dev

Objective-C: Simulating slow network speeds

Tis' the holiday to be lazy... Sorry guys, holiday season and thus I have been a bit slack on my blog postings. Anyhow, a free little Christmas gift for you all.

If you want to simulate on your iPhone Simulator, slow internet speeds, to test 3G and 2G speeds, this is the perfect tool for you. SpeedLimit is a free tool that allows you to pre-select in your Leopard preference pane, a couple of options, from 768k DSL, Edge, 3G and Dialup. 

Have a happy holidays guys!

speedlimit pref panel shot

14