• Stars
    star
    157
  • Rank 238,399 (Top 5 %)
  • Language
    Objective-C
  • Created about 11 years ago
  • Updated almost 11 years ago

Reviews

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

Repository Details

Sample project showing a common architecture I use when creating iOS Projects

iOSArchitecture

Sample project showing a common architecture I use when creating iOS Projects.

The project itself is quite simple:

  • Getting Yahoo's Sports feed from their XML RSS.
  • Parsing it
  • Returning the results to the UIViewController, where then they can be showed.

There is a Branding part, where I expose a strategy to deal with this. So:

  • We have two brands: Nike and Adidas.
  • Depending on being on Debug or not, we will choose the right one to be used.

There are many ways of doing it, although I think mine has some advantages.


Requirements

You will need cocoapods in order to build this project


Goals of this Project

One of the main issues across the iOS development ecosystem is the lack of a well stablished architecture, from small to big applications.
There is also a huge gap of Repositories/Projects/Samples that show what an app should look like, from a architectural point of view.

You can see that when:

  • You have Logic mixed with UI.
  • You cannot see the boundaries between the Controller and the Model (MVC)
  • Your UIViewControllers surpass 300 lines (From my experience when a UIViewController passes that frontier, normally something could be done better)
  • It's not clear for you where things are and how to use them.

Each project has it's own demons, so what I want with this sample project, is a way for iOS developers to have a reference for what they should always try to achieve:

  • Strive for small, simple, clean, understandable and maintainable classes.
  • Respect the SOLID principles.
  • Respect the DRY Principle.
  • Respect the 4 OOP principles: Encapsulation, Abstraction, Inheritance, Polymorphism.
  • Create methods that do one thing and one thing only (this is specially useful for Unit Testing).
  • Create meaningful names for your methods, classes, variables, properties. This is one of the most underestimated part of coding.

How to use this Project

Start by adding some breakpoints and keep pushing until you understand what's going on. If you find it's a bit difficult to use/understand it, send me a tweet, or open an issue, and I will try to assist the best I can. If you happen to use this architecture in one of your apps, just flag it for me. :)


Suggestions

I am more than happy to change the current structure of this project, based on people's suggestions. The goal here is to improve the way we code. So please, if you think that something is fundamentaly wrong, or that could be improved, open an issue, create a pull request or just let me know.


Versions

1.3

Added an example of how branding can be achieved and architected inside an iOS application. As explained, on the commit message, different strategies can be putted in place, depending on how you want the branding to behave. For example, some branding besides images, also change the overall layout of the UI (position of the elements on the screen).

In this case I use a class called RPBrandingFactory responsible for returning a Class <RPImagesBrandingProtocol> that is able to respond to certain messages (in this case related to how we deal with images). The use of a protocol + Class, makes it easier to use (as the class, in the end of the day, acts as a Factory) and flexible to add, in the future, other brands.

1.2

An object of type id <RPSportsBoundaryProtocol> can now the be injected into the RPSportsFeedViewController (you can see this as he complies to the RPDataSourceManagerInjection protocol). By default it will be used RPDataSourceManager. This is specially useful for Unit Testing, as you can inject a mock one. I also added an example of how to do it on the test suite (check the RPSportsFeedViewControllerTesting.m and RPMockDataSourceManager). The RPSportsBoundaryProtocol is now expecting an object (as the method -(void)yahooSportsFeedWithCompletion:(RPYahooSportsCompletionBlock)completionBlock is an instance one) ) versus a class, although I am still weighting the pros and cons.

1.1

The access to the Model, by the UIViewControllers, are now made by a Interactor object. Instead of returning a reference to the RPDataSourceManager Class (since we are using class methods), we return an abstract Class that conforms to a given protocol. You can see this see this strategy applied here, the video is present by Robert Martin aka Uncle Bob.


License

This code is distributed under the terms and conditions of the MIT license.

Bitdeli Badge

More Repositories

1

UIViewController-Swizzled

Used to print the structure of your application as you use it
Objective-C
847
star
2

Receiver

Swift µframework implementing the Observer pattern 📡
Swift
239
star
3

Reactor

Powering your RAC architecture
Swift
184
star
4

OptionalExtensions

Swift µframework with extensions for the Optional Type
Swift
182
star
5

Swift-Sugar

Swift's Sugar. Heavily inspired on Objc Sugar(https://github.com/supermarin/ObjectiveSugar)
Swift
153
star
6

Tangerine

Swift µframework for fetching images 🍊
Swift
149
star
7

Rinku

A simple networking library
Swift
43
star
8

KirKos

Focus on the most important
Objective-C
34
star
9

SaferFonts

Avoiding potential mistypes while using fonts programatically in Swift
Swift
30
star
10

RPNSURLConnection-Swizzled

NSURLConnection's category for the request and stack trace output
Objective-C
26
star
11

RPDynamicWarningView

A simple warning view that takes advantage of UIKit Dynamics
Objective-C
22
star
12

NSURLConnection-Blocks

Category that allows the dev to specify blocks for the success and failure cases
Objective-C
13
star
13

UITextField-DelegationBlocks

Add blocks, as per a single instance basis, to your UITextFields
Objective-C
12
star
14

NSObject-Dealloc

Category used to know when your object has been deallocated
Objective-C
7
star
15

8472

Strava client, with focus activities analysis. 🏃‍♂️
Swift
6
star
16

JSaaS

Jaden Smith as a Service
Elixir
6
star
17

NSPortoWorkshop

A detailed description about a potential Workshop that could be organised in Porto, Portugal.
5
star
18

SliderController

Objective-C
5
star
19

fartlek

Strava Webhooks + APNS
Python
5
star
20

RPGallery

Gallery used to upload pictures
Objective-C
4
star
21

TeamGen

Generating balanced teams 🚀🏈
Swift
4
star
22

OctifyIssues

Used as Issues Tracker for the App Octo Alarm
3
star
23

FootballTeamGenerator

...because just random is not good enough
Swift
3
star
24

RuiAAPeres

2
star
25

ReversePolishNotation-Swift

Reverse Polish Notation done in Swift, based on http://learnyousomeerlang.com/functionally-solving-problems#rpn-calculator
Swift
2
star
26

but_the_android_team_uses_RxJava

this is a parody
Swift
2
star
27

OctifyPush

APNS for my iOS App (Octify)
Go
2
star
28

TestingFRP

Some benchmarks
Swift
2
star
29

SquareStock

Square Stock
Objective-C
1
star
30

Refactoring

Swift
1
star
31

Franz

Swift
1
star
32

Reading18

A list of material (articles + books) I read + wrote in 2018.
1
star
33

swiftAveiroFP

FP stuff with Argo Fun
Swift
1
star
34

principles

1
star
35

PromisesPlayground

Objective-C
1
star