Skip to content

Instantly share code, notes, and snippets.

View ivangodfather's full-sized avatar
🍂

Ivan Ruiz ivangodfather

🍂
View GitHub Profile
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
TagCollectionViewCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
[cell.tagNameButton setFrame:CGRectMake(10,0,200, 100)];
return cell;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
TagCollectionViewCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
[cell.tagNameButton setTitle:@"Test" forState:UIControlStateNormal];
cell.backgroundColor = [UIColor redColor];
cell.tagNameButton.titleLabel.text = @"Test";
// UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 80, 20)];
// [button setTitle:@"OtherTest" forState:UIControlStateNormal];
// [cell.contentView addSubview:button];
// Those commented lines works
alert.addAction(UIAlertAction(title: "fdafd", style: UIAlertActionStyle.Default, handler: { (whatever) -> Void in
doSomething()
}))
#define URL_STRING @"http://mydomain.com/nextEvents"
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:URL_STRING]];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (!connectionError && data) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
}
[message.image getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
image = [UIImage imageWithData:data];
dispatch_async(dispatch_get_main_queue(), ^{
cell.photoImageView.image = image; //this not
[self.cameraButton setBackgroundImage:image forState:UIControlStateNormal]; //this changes
});
}];
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
//some code
[message.image getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
image = [UIImage imageWithData:data];
cell.photoImageView.image = image; //This doesnt get update. but i cant reload this indexPath cause i will create a infinite loop;
self.testImageView.image = image; //This get update.
}];
//other code
NSMutableArray *CustomClassArray = //Objects of type array
class CustomClass : Object
{
@property NSString *objectID;
}
NSMutableArray *filteredArray = [NSMutableArray new];
NSInteger item = [self.collectionView numberOfItemsInSection:0] - 1;
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:item inSection:0];
[self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
NSDate *date = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSInteger comps = (NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit);
NSDateComponents *dateComponents = [calendar components:comps
fromDate: date];
NSDate *finalDate = [calendar dateFromComponents:dateComponents];
NSLog(@"FINAL DATE %@",finalDate);
[~/desktop/test] git:master $ cat file
modified by newBranch
[~/desktop/test] git:master $ ls
file
[~/desktop/test] git:master $ git checkout newBranch
M file
Switched to branch 'newBranch'
[~/desktop/test] git:newBranch $ ls
file
[~/desktop/test] git:newBranch $ echo "test" > anotherFile