objcio / issue-1-lighter-view-controllers Goto Github PK
View Code? Open in Web Editor NEWExample project for the 1st issue of objc.io
Example project for the 1st issue of objc.io
如果传递给DataSource里边的array在外部需要动态改变呢,这个时候怎么再次传递给tablview呢
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?
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.
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:
I have added 'HomeViewController' as rootviewcontroller of navigation controller. HomeVC has a button 'Launch'. Memory usage till point is 14.4MB.
Action on 'Lunch' button will push 'PhotosViewController'. Memory usage after successful loading of 'PhotosViewController' is 17.3MB.
'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];
}
Just clone the source code, update submodule, and run the test
Note: the app is built and run normally
你这个demo cell高度都是固定的,现实项目中 cell动态的多,咋算高度啊?咋封装
但是代码那么绕 ,看着不辛苦吗
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.