Code Monkey home page Code Monkey logo

issue-1-lighter-view-controllers's Introduction

objc.io sample project for issue #1: lighter view controllers

This project serves as an example for the topics discussed in the inaugural edition of objc.io. This app is a very simple and contrived example, which only serves the purpose of showing the discussed techniques in context.

This app comes with a predownloaded archive of photo records from 500px, and displays them with some additional details. We only show the metadata of the photos and the pictures itself, because we didn't want to add networking and the complexity of presenting downloaded photos in table view cells in a good way, so that we can concentrate on the techniques discussed in this edition.

Cloning this project

To get the tests to run, you need to install the OCMock dependency by running the following commands:

git submodule init
git submodule update

issue-1-lighter-view-controllers's People

Contributors

chriseidhof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

issue-1-lighter-view-controllers's Issues

'Photo' objects are leaking

Hi,

'Photo' objects never get released which results in memory leaks.

'ArrayDataSource' copies block of type 'TableViewCellConfigureBlock'.
I think during this copy of block, 'Photo' instances are copied and retained too.

I put following NSLog statement in Photo which never get printed.

// Photo.m
-(void) dealloc
{
NSLog(@"%s",PRETTY_FUNCTION);
}


In fact, I profiled memory footprint in instruments. It goes like this:

  1. I have added 'HomeViewController' as rootviewcontroller of navigation controller. HomeVC has a button 'Launch'. Memory usage till point is 14.4MB.

  2. Action on 'Lunch' button will push 'PhotosViewController'. Memory usage after successful loading of 'PhotosViewController' is 17.3MB.

  3. 'Back' button in navigation bar, pops 'PhotosViewController' & 'HomeViewController' appears. Memory usage till point is 16.2MB. I was expecting it to be close to 14.3MB

//AppDelegate.M
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
HomeViewController * hmv = [HomeViewController new];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:hmv];
....
}

//HomeViewController.m
-(IBAction) launch:(id)sender
{
PhotosViewController *photosViewController = [[PhotosViewController alloc] initWithNibName:@"PhotosViewController"
bundle:nil];
[self.navigationController pushViewController:photosViewController animated:YES];
}

Why not just place data source methods into a superclass?

I'm at a loss to the advantage here. Seems to me you'd have the same amount of code, and the same number of files if you just moved the code to a superclass rather than another object.

Ex:
superclass with photoDataSource methods
subclass
2 files

object with photoDataSource methods
uiviewcontroller with object set as datasource
2 files

Is there an advantage I am missing to not just placing all the photoDataSource methods into a superclass rather than a separate object?

How to handle multiple custom cells?

This approach works great for having one custom cell per table view. But how would one handle multiple customs cells with this approach? Saying you would like to use different cell layouts based on your model attributes.

你好 问个问题

你这个demo cell高度都是固定的,现实项目中 cell动态的多,咋算高度啊?咋封装

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.