Skip to content

Instantly share code, notes, and snippets.

@Rich86man
Rich86man / MKOverlayviewFucntions.m
Created May 9, 2012 02:14
MKOverlayView Fucntions
- (BOOL)canDrawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale {
NSURL* fileURL = [(HeatMap*)self.overlay localUrlForStyle:@"classic" withMapRect:mapRect andZoomScale:zoomScale];
if([[NSFileManager defaultManager] fileExistsAtPath:[fileURL path]])
return YES;
[(HeatMap*)self.overlay fetchFileForStyle:@"classic" withMapRect:mapRect zoomScale:zoomScale completion:^{
[self setNeedsDisplayInMapRect:mapRect zoomScale:zoomScale];
}];
@Rich86man
Rich86man / gist:3130884
Created July 17, 2012 18:04
UIScrollview page number
CGFloat pageWidth = scrollView.frame.size.width;
int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
@Rich86man
Rich86man / gist:3242060
Created August 2, 2012 23:38
Initial try
- (void)testTabsGetNotified
{
[[mockController stub] requestSessionId];
[[mockController stub] endVisit];
id mockVideoController = [OCMockObject partialMockForObject:playgroundController.videoController];
id mockArtController = [OCMockObject partialMockForObject:playgroundController.artController];
- (void)testBottomGradientGetsAdded
{
[[mockController expect] addBottomGradient:viewController.basicFeaturesHeader];
[[mockController expect] addBottomGradient:viewController.premiumFeaturesHeader];
[viewController viewDidLoad];
[mockController verify];
}
- (void)purchaseBook:(ZOBook*)aBook
{
NSDictionary * params = @{ @"book_id" : aBook.serverId };
ZORequestExecutor * request = [ [ZORequestExecutor sharedFactory ] executorWithDelegate: self
resource: [NSString stringWithFormat: @"%@/%@/purchase", self.resourcePath, aBook.serverId]
params: nil ];
[ request post ];
}
- (void)zoodlesPurchaseDidFinish
{
[self.cellBeingPurchased hideProcessingPayment];
self.midTransaction = NO;
[self.booksFetchController performFetch:nil];
[self.tableView reloadData];
[[ZOStore sharedStore] setDelegate:nil];
// Invalidate the ZOReading's so a newly purchased book
- (void) invalidateInContext:(NSManagedObjectContext *)context
{
NSFetchRequest* request = [[NSFetchRequest alloc]initWithEntityName:kZODownloadName];
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"targetEntity == %@", self.modelClassString];
request.predicate = predicate;
NSArray* downloads = [context executeFetchRequest:request error:nil];
for (ZODownload* download in downloads) {
self.view.frame = CGRectMake(0, 0, DeviceSpecificSetting(480, 568), 320);
- OR -
NSInteger width = DeviceSpecificSetting(480, 568);
self.view.frame = CGRectMake(0, 0, width, 320);
- (void)requestBooks
{
[self.activityIndicator startAnimating];
self.booksResource = [[ZOBookResource alloc] initWithKidId:nil
delegate:self
finished:@selector(requestBooksFinished)
failed:nil];
[self.booksResource index];
}
- ( void ) updateWithDictionary: ( NSDictionary * ) dict {
if( !dict ) { return; }
NSString * dateString = [ dict objectForKey: @"created_at" ];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[ dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
NSDate* date = [dateFormatter dateFromString:dateString];
self.createdAt = date;
self.serverId = [ dict objectForKey: @"id" ];