This project only purpose is to provide brief, clean and readable code in a dummy application. It is heavily library based and MVC oriented and shows mecanisms like downloading, storing and displaying data from a webservice. All data is handled with the Realm library, using the Active Record Pattern for cleaner code while still providing excellent performances.
You are of course invited to use, fork and improve this project using your own knowledge. I'll try to update the code with up to date libraries and cconventions.
Here is the file hierarchy as is in the project. We aim to have a clear view of our MVC components.
.
|-- Classes
| |-- AppDelegate.h
| |-- AppDelegate.m
| |-- Constants.h
| |-- Models
| |-- Controllers
| |-- Views
| |-- Helpers
|-- Supporting Files
|-- Resources
|-- Images
|-- Frameworks
|-- Products
|-- Pods.xcconfig
In this project I rely on some naming conventions :
- ViewControllers are suffixed by 'VC'
- Models should be self-explanatory and match the server model (if any)
- Custom views should indicate the superclass type (like
ColorCell
which extendsUITableViewCell
)
- Networking methods should always begin with the keyword
request
, likerequestColors
- User interaction method should always begin with
select
All code should respect (K&R style : http://en.wikipedia.org/wiki/Indent_style#K.26R_style)
- (void) foo
{
if(bar == 1){
bar = 2;
}
}
Use fast declarations as much as possible gives a more readable, less cluttered code.
// Arrays
// No
[NSArray array];
[NSArray arrayWithObjects:@"foo", @"bar",nil];
[array objectAtIndex:index];
// Yes
@[];
@[@"foo",@"bar"];
array[index];
// Dictionaries
// No
[NSDictionary dictionary];
[NSDictionary dictionaryWithObjects:@"object", @"key",nil];
[dictionary objectForKey:key];
// Yes
@{};
@{@"key" : @"object"};
dictionary[key];
// Numbers
// No
[NSNumber numberWithInt:1];
// Yes
@1;
Dependencies are managed with CocoaPods, which I recommend you to have a look at : http://cocoapods.org/
git clone [email protected]:kirualex/ColourLove.git
cd ColourLove
gem install cocoapods
pod setup
pod install
open ColourLove.xcworkspace