
IOS Boilerplate: A base template for iOS apps - jamesjyu
http://iosboilerplate.com/
======
zbowling
This isn't really necessary and most of these packages will be obsolete in iOS
5 and using a few them (like ASIHTTPRequest) will get you in trouble with ARC.

* JSONKit - It's an ok choice but there are literally 5 choices I can think of off the top of my head (not including the now built in JSON support in Lion and iOS 5). I prefer SBJSON because it was once benchmarked with the fastest read speed and it has a dirt simple interface for me as a dev.

* ASIHTTPRequest - I used to swear by it, but now NSURLConnection in Lion (and iOS 5) has async methods with blocks. ASIHTTPRequest doesn't play nicely with ARC because it doesn't have a conventional pattern to object ownership (design to make it less to work to deal by deallocing itself for async usage).

* ImageManager - cute, but it's one of many solutions and this one takes some of the cache control out of my hands. I don't believe it resuses ASIHTTPRequest so now I have two HTTP libraries in my project and I'm juggling between both.

* The numerous category packages to extend and add convenience methods - these are all cute but I like to take things on a case by case basis and not add code bloat and unused functionality in one shot.

The problem that I have is that unlike HTML5 boilerplate which is a common
subset of the absolute minimum you are going to need 99% of the time that is
put together in the best possible manor, this is just a collection of various
packages that you probably will not end up using more than 50% of in most
applications. It's not really a "boilerplate" for that reason.

Edit: my coworker sent me this when he saw I wrote this reply -
<http://xkcd.com/386/>

~~~
zbowling
So here is my solution after giving it a little thought:

Instead of a base template project, we need a modular system for adding
dependent packages on a case by case basis similar to python eggs and ruby
gems. Just a simple set of command line tools.

Then you could build a central repository of formula scripts for adding
frameworks to your project (maybe something simple like how homebrew just uses
really simple ruby scripts and built in git awesomeness to keep it up to date
and power a good portion of itself and allow others to submit forumlas via
pull requests).

The formulas could pull down code from these various project's hosts on an as
needed basis and they could be downloaded right into a standard "/vendor/"
folder in your project directory when installed. A file would created with
install info and time it was pulled so you could easily update the project
later with another command.

Then maybe update (or maybe not) update your project file to reference it, add
target dependencies, add header search paths or copy file operations for
frameworks, etc. (This could be done by generating a base xcconfig file that
links in xcconfig files provided by each forumla install into the project).

All these packages could be added to this system and allow the user to search
and find great libraries, install them, keep them up to date, and whatever.

(If no body else does this, I may end up do it actually)

~~~
eraserhd
I have started something like this, although I would barely call it alpha at
this point. I would be willing to abandon it and contribute my effort
elsewhere if there's another project further along or with a better design,
but I offer mine for consideration.

<https://github.com/eraserhd/acd>

It's in the process of being renamed apothecary. It's based around using git
submodules for importing other people's code. I was really tired of
instructions like, "copy all of these files into your project." (Really?!)

~~~
bbsabelli
You mean like your "Contributing to acd" instructions? :)

------
gimenete
Hi,

I'm the person behind IOS Boilerplate. I didn't expect to appear at Hacker
News. Sorry for the typos, I wrote the web site in less than 1 hour and I
didn't check the spelling.

This project is work in progress. I'm learning from your comments and I will
improve it. I just hope it to be helpful for some of you.

I will try to reply to some of your comments directly.

Thanks!

------
steipete
There are much better choices now, this project is a bit outdated.

I'd base a new app on AFNetworking, not asi. ImageManager is not needed, as
AFNetworking is better suited.

Pull-down-to-refresh is overused already, and most times the wrong context.
(Originally, you were loading new tweets ON TOP, not general loading)

The whole tableview examples shouldn't be necessary.

I wouldn't put maps in a example, most apps aren't gonna use it.

JSONKit is great, but also soon iOS4-Legacy.

Adding SVProgressHUD only leads to apps that over-use the modal-loading
principle, like the GitHub Issues app. The better way is to make a non-
obstrusive, non-modal loading inside the controller, which can be cancelled
anytime.

As for the random categories... meh. Get BlocksKit or something actually
useful.

~~~
tstyle
"ImageManager is not needed". As a novice to iOS programming, I'm curious to
know what is the preferred way to retrieve and cache remote images and display
them in an ImageView. Thanks.

------
mprovo1
Good job, I love this. I find that FastCells are less useful these days as
iphone 3G are less common. I prefer to design my complex cells in interface
builder for ease of maintenance. But it's just personal taste. Otherwise,
everything in there should be very useful for almost any app. I suggest you
add support for external services, like Facebook for instance (which a lot of
projects use).

BTW, I love DictionaryHelper, it definitely saves you a lot of headaches if
you work with a JSON api!

~~~
Greenisus
I still find FastCells useful if you're laying out cells with lots of
subviews, even on modern iOS devices.

------
smharris65
How does this project compare to the three320 project originally started by
Joe Hewitt from Facebook? 320 seems to have more features:

<https://github.com/facebook/three20/>

~~~
gte910h
320 is a little bloated and pretty difficult to keep working in Xcode 4 today.

The 320 devs appear to still be on Xcode3, and demand a bunch of nonstandard
settings on Xcode4 to make it work (including a scary script which edits your
project in all sorts of ways).

------
henry501
Despite the typos, it does look interesting.

Is there anything similar for Android?

~~~
div
It's not really a boilerplate version, but there's a great answer on
StackOverflow that keeps a list of pretty solid 3rd party libraries.

[http://stackoverflow.com/questions/4078479/what-
android-3rd-...](http://stackoverflow.com/questions/4078479/what-android-3rd-
party-libraries-are-there/4078596#4078596)

------
epo
Typo 2nd bullet, "freamwork", 3rd bullet "intented".

Actually, I'll stop there. Lots of typos, you should get them fixed, it makes
you look sloppy.

~~~
Aqua_Geek
Forked, fixed, and pull request sent: <https://github.com/gimenete/iOS-
boilerplate/pull/1>

~~~
gimenete
Thanks a lot. I merged your changes :)

------
sunkencity
Nice!

For this to be really useful though I'd like to see all included projects
being MIT licensed or something. Now it's a mixture of no license at all
(EGOTableViewPullRefresh), BSH (ASIHttprequest), JSONKit is well licensed with
dual BSD License/Apache License, SVProgressHUD has a license but it seems home
made. And what is the license of the actual boilerplate?

~~~
gimenete
I have added the license terms in each file I have created. Any suggestion is
welcome. I just want anybody to be able to use it without limitations, just
keeping the copyright notice.

------
matttthompson
A much easier way to add async HTTP and image requests would be to just use
AFNetworking (<https://github.com/gowalla/AFNetworking>)

The rest of this I could really take or leave. Really wish there was something
better than EGOPullToRefresh in wide use...

~~~
Greenisus
How is AFNetworking easier than ASIHTTPRequest?

~~~
matttthompson
Simple block-based API, significantly less lines of code to accomplish the
same tasks, and smaller, more understandable codebase that uses Foundation
classes (e.g. NSURLRequest, NSURLResponse, etc.), rather than re-inventing the
wheel

And though I don't have the exact numbers, AFNetworking is really fast, maybe
2-3x over ASI in average cases, from my experience and what other users
report.

Take a look at the examples in the README and compare that to how you'd do the
same in ASI.

~~~
hamedh
doesn't ASI also use blocks? its syntax is very similar. but i didn't know
about that it's much faster than ASI, thanks for that

------
fady
Ever since HTML5 Boilerplate was launched, a whole plethora of projects have
been popping up which were inspired by it. Thanks to all the main devs of H5
Boilerplate and projects a like. Makes learning easier and fun!

------
shadowmatter
Looks good. Just FYI: There's already a MapKit class called MKPointAnnotation
that provides a simple implementation of MKAnnotation, so your Place class is
redundant:

    
    
        MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
        point.coordinate = CLLocationCoordinate2DMake(35.01234, -115.56789);
        point.title = @"The title!";
        point.subtitle = @"The subtitle!";
        [point release];

~~~
gimenete
Thanks for your comment. I didn't know about MKPointAnnotation.

------
awolf
>There is an example of how to calculate the directions between two points
using the Google Maps API and showing it on a MKMapView using map overlays.
See DirectionsExample.m.

FYI I believe using the Google Maps API in this manner runs afoul of Google's
terms. Google only wants you to use their directions information on top of
maps loaded for web sites via their JavaScript interface. MKMapView doesn't
qualify.

------
stealingyocode
I stole a few categories from you into my Category Repo.Hope you dont mind.
<https://samyzee@github.com/samyzee/Additions>

You can add my category repo as a git submodule the boilerplate if you want.I
have some cool stuff in there!

EDIT:link

------
Greenisus
When I saw this, I thought "wow, this is pretty much exactly the same stuff I
include every time I start a new iOS project."

I feel like it would make more sense as a project template though. It seems
like if I use this to start a new project, I need to clone the repo and then
change a lot of classes to get started. Or am I missing something?

~~~
reidmain
Having to copy in 4-5 frameworks every time you start a project is not a bad
thing.

Alternatives are always emerging to even the most used frameworks. Every time
I start a project it is a time to look and see if there are better ways to do
things.

Also including frameworks that you will never use is bad practice. Most apps
are not going to make use of MapKit. If you're not going to use it why bother
bloating your project?

~~~
Greenisus
i agree with you, especially on not including MapKit

------
sedev
As someone just getting into iOS, this looks very useful, because it's a bunch
of coherent ObjC code to read, presented in a beginner-friendly way. I'm also
glad I read the HN critiques, though - knowing that some of this will be
batteries-included in iOS 5 is valuable.

------
danssig
Interesting stuff. Does anyone have a "goto" list of IOS libraries documented
anywhere? I've heard there's a nice DRM library for IOS apps but I haven't had
any luck finding it so far.

------
alexbell
This is great so far, you have an excellent taste in frameworks. It's also
nice and light weight. I would suggest adding a singleton macro. Will try and
put some of the boilerplate stuff I use in as a pull request when I get the
time.

~~~
lukeredpath
I'm no fan of singletons either, but writing one with GCD dispatch_once is
pretty simple. Nevertheless, I do have a macro for it:

[http://lukeredpath.co.uk/blog/a-note-on-objective-c-
singleto...](http://lukeredpath.co.uk/blog/a-note-on-objective-c-
singletons.html)

It's really for creating "shared" instances rather than true singletons, but
who honestly needs a real singleton?

~~~
alexbell
This is cool!

------
Joshim5
Typo - "It is not intended to be a freamwork"

~~~
gimenete
Thanks. Solved :)

------
ThomPete
This would be much more interesting for the Android IMHO.

Anyone want to work on that and I would be up for it.

~~~
Mizza
I've been thinking about doing this for a while - I basically have one that I
use for my personal projects, but I could clean it up and document it and use
make it a public boilerplate.

What features would you guys want? Here's what I'd include:

* Robust JSON parsing examples feeding to a.. * Speedy list view * Grid and List Menu Views * DataTask examples * Splash screen * Palette values, Gradients in XML * GeoLocation Snippets * Nice defaults for text appearance * Background service example * Internet permissions

Anything you guys would want?

~~~
burnstek
Code to extend the Google Map component (such as a clickable BalloonOverlay,
fast OverlayItem grouping). I'd contribute my own code for this to such a
project.

------
irvingruan
Very cool, thanks!

------
benguild
This is awesome!

