Skip to content

Instantly share code, notes, and snippets.

View spacedrabbit's full-sized avatar

Louis T. spacedrabbit

View GitHub Profile
UIView * bottomContentView = [[UIView alloc] init];
[bottomContentView setBackgroundColor:[UIColor darkGrayColor]];
[bottomScrollView addSubview:bottomContentView];
NSArray * contentView = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[bottomContentView]|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(bottomContentView)];
NSArray * contentViewHeight = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[bottomContentView]|"
options:0
@property (strong, nonatomic) NSMutableArray * bombAssPugBomb; // URL strings
@property (strong, nonatomic) __block NSMutableArray * pugImages; // Images
// we use a block macro to be able to use this array in a block
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//1
FISPugCell * pugCell = (FISPugCell *)[tableView dequeueReusableCellWithIdentifier:@"pugCell"];
//2
[pugCell.pugImageView setContentMode:UIViewContentModeScaleAspectFit];
//3
[pugCell.pugImageView setImage:self.pugImages[indexPath.section]];
return pugCell;
NSLog(@"You want a response? %@", responseObject); // 1
NSURL * pugURL = [NSURL URLWithString:responseObject[@"pug"]];
[self.bombAssPugBomb addObject:responseObject[@"pug"]]; //2
NSURLRequest * pugImageRequest = [NSURLRequest requestWithURL:pugURL];
AFHTTPRequestOperation * pugImageOperation = [[AFHTTPRequestOperation alloc] initWithRequest:pugImageRequest];
AFImageResponseSerializer * pugImageSerializer = [AFImageResponseSerializer serializer];
pugImageOperation.responseSerializer = pugImageSerializer;
[pugImageOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
UIImage * pugImage = (UIImage *)responseObject;
// 1
[[NSOperationQueue mainQueue] addOperationWithBlock:^
{
imageBlock(pugImage);
[self.tableView reloadData];
}];
#import "LDTHomeCatViewController.h"
#import "CatGridView.h"
@interface LDTHomeCatViewController ()
@end
@implementation LDTHomeCatViewController
- (void)viewDidLoad {
-(void)awakeFromNib{
NSDictionary * catImageReferences = NSDictionaryOfVariableBindings(_topLeftCat, _topRightCat, _bottomLeftCat, _bottomRightCat);
NSDictionary * catMetrics = @{ @"catImageWidth" : [NSNumber numberWithFloat:150.0],
@"catImageHeight" : [NSNumber numberWithFloat:120.0]
};
NSArray * topRowOfCats = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[_topLeftCat(==catImageWidth)]-10-[_topRightCat]-|"
options:0
metrics:catMetrics
@implementation CatGridView
-(void)awakeFromNib{
NSDictionary * catImageReferences = NSDictionaryOfVariableBindings(_topLeftCat, _topRightCat, _bottomLeftCat, _bottomRightCat);
NSDictionary * catMetrics = @{ @"catImageWidth" : [NSNumber numberWithFloat:150.0],
@"catImageHeight" : [NSNumber numberWithFloat:120.0]
};
NSArray * topRowOfCats = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[_topLeftCat(==catImageWidth)]-10-[_topRightCat]-|"
- (void)viewDidLoad {
[super viewDidLoad];
UINib * gitNib = [UINib nibWithNibName:@"gitHubLogin"
bundle:[NSBundle mainBundle]];
GitHubLogin * loginView = [[gitNib instantiateWithOwner:self options:nil] firstObject];
[self.view addSubview:loginView];
[loginView setFrame:self.view.frame];
}