Skip to content

Instantly share code, notes, and snippets.

-(void)configureWithVenue:(Venue *)venue
{
self.venueName = venue.name;
self.addressLabel.text = [venue.address fullAddressWithMultipleLines:YES includeCountry:NO];
dispatch_async(dispatch_get_main_queue(), ^{
if(nil == self.mapView) {
MKMapView *mapView = [[MKMapView alloc] initWithFrame:self.mapViewContainer.bounds];
self.mapView = mapView;
[self.mapViewContainer addSubview:mapView];
@jerryhjones
jerryhjones / gist:6895805
Created October 9, 2013 03:34
SMLBookshelfTransitionAnimator
SMLBookshelfTransitionAnimator *animator = [[SMLBookshelfTransitionAnimator alloc] init];
animator.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"left.jpg"]];
animator.rightView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"right.jpg"]];
animator.dismissing = YES; // Required to automaticaly handle left/right sides
- (void)flipButtonPressed:(id)sender
{
if (self.currentView == self.primaryView) {
self.cardBackView.showTellMeWhenSwitch = YES;
__block UIImage *image = self.eventCardView.eventImageView.image;
__weak GSEventStarCollectionViewCell *weakSelf = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
image = [image applyMediumDarkEffectWithBlurRadius:10.0f];
dispatch_async(dispatch_get_main_queue(), ^{
weakSelf.cardBackView.imageView.image = image;
NSMutableDictionary *mutableAttributeValues = [attributeValues mutableCopy];
NSString *resourceIdentifier = AFResourceIdentifierFromReferenceObject([self referenceObjectForObjectID:objectID]);
[childContext performBlock:^{
[backingContext performBlockAndWait:^{
NSManagedObjectID *backingObjectID = [self objectIDForBackingObjectForEntity:entity withResourceIdentifier:resourceIdentifier];
NSManagedObject *backingObject = [backingContext existingObjectWithID:backingObjectID error:nil];
[backingObject setValuesForKeysWithDictionary:mutableAttributeValues];
@property (nonatomic, weak) UIView *someViewA;
@property (nonatomic, weak) UIView *someViewB;
- (void)someMethod
{
NSLog(@"view: %@", self.someViewA); // Prints a nil value
NSLog(@"view: %@", self.someViewB); // Prints the view
}
- (UIView *)someViewA
- (void)_updateCurrentEventController
{
NSInteger pageIndex = floorf(scrollView.contentOffset.x / scrollView.bounds.size.width);
if (pageControl.currentPage == pageIndex) {
return;
}
// Put your event code somewhere here or after
NSArray *dates = [events dates];
- (void)scrollViewDidEndDragging:(UIScrollView *)theScrollView willDecelerate:(BOOL)decelerate
{
if (NO == decelerate) {
[self _updateCurrentEventController];
}
}
- (void)authenticateLocalPlayer
{
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {
[self callSelfOnMainThread:@selector(didAuthenticateLocalPlayer:) withArg:error error:nil];
}];
}
- (void)callSelf:(SEL)selector withArg:(id)arg error:(NSError*)err
{
assert([NSThread isMainThread]);
// NOTE: GameCenter does not guarantee that callback blocks will be execute on the main thread.
// As such, your application needs to be very careful in how it handles references to view
// controllers. If a view controller is referenced in a block that executes on a secondary queue,
// that view controller may be released (and dealloc'd) outside the main queue. This is true
// even if the actual block is scheduled on the main thread. In concrete terms, this code
// snippet is not safe, even though viewController is dispatching to the main queue:
//
// [object doSomethingWithCallback: ^()
// {
// dispatch_async(dispatch_get_main_queue(), ^(void)