Skip to content

Instantly share code, notes, and snippets.

View Dimillian's full-sized avatar
📱
SwiftUI EVERYWHERE

Thomas Ricouard Dimillian

📱
SwiftUI EVERYWHERE
View GitHub Profile
@Dimillian
Dimillian / gist:2044138
Created March 15, 2012 13:13
Blocks REST
{
MSheaderSeeenViewCell *clickedCell = (MSheaderSeeenViewCell *)[[sender superview]superview];
[clickedCell.indicator startAnimating];
[sender setHidden:YES];
MSMovie *movie = [movies objectAtIndex:[self.tableView indexPathForCell:clickedCell].row];
MSRESTRequest *getInfoRequest = [[MSRESTRequest alloc]initWithMethod:@"GET"
ressource:@"movies"
parameters:[NSArray arrayWithObject:
[NSString stringWithFormat:@"movie_id=%@", movie.udid]]
shouldEscapeParameters:YES];
@Dimillian
Dimillian / gist:2954027
Created June 19, 2012 12:58
BLOCK BLOCK BLOCK
//Recreate a partial route from server response, usefull in case of crash or other
+(void)recreateRouteFromCurrentServerRoute:(void (^)(WZRoute *))handler
{
//Ask the server if the current user have a route to take action for
DMRESTRequest *request = [[DMRESTRequest alloc]initWithMethod:@"GET" ressource:@"routes/current" parameters:nil shouldEscapeParameters:NO];
[request executeBlockRequest:^(NSURLResponse *response, NSData *data, NSError *error){
if (data) {
NSJSONSerialization *json = [NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingMutableLeaves
error:nil];
@Dimillian
Dimillian / gist:3152851
Created July 20, 2012 19:54
Inject UI in phonegap
- (void)webViewDidStartLoad:(UIWebView *)theWebView
{
if (firstLaunch) {
firstLaunch = NO;
//As phonegap overwrite the main UI privately this method is used as the entry point to inject custom UI
//Phonegap nib are loaded and displayed, so safe to move them to another view
[self injectCustomUI];
}
@Dimillian
Dimillian / gist:3807501
Created September 30, 2012 16:37
isIphone5
+(BOOL)isIphone5
{
if ([[UIScreen mainScreen]bounds].size.height == 568.0) {
return YES;
}
return NO;
}
-(void)onTwitterButton:(id)sender
{
if ([TWTweetComposeViewController canSendTweet]) {
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[HUD show:YES];
[account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error){
dispatch_async(dispatch_get_main_queue(), ^{
if (granted){
//
// MSJSonParser.m
// MySeeen
//
// Created by Thomas Ricouard on 11/02/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "MSJSonParser.h"
- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeObject:self.udid forKey:@"udid"];
[coder encodeObject:self.title forKey:@"title"];
[coder encodeObject:self.alternateTitle forKey:@"alternateTitle"];
[coder encodeObject:self.subtitle forKey:@"subtitle"];
[coder encodeObject:self.seenStatus forKey:@"seenStatus"];
[coder encodeObject:self.tinyImageLink forKey:@"tinyImageLink"];
[coder encodeObject:self.normalImageLink forKey:@"normalImageLink"];
//Creating a file path under iOS:
//1) Search for the app's documents directory (copy+paste from Documentation)
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//2) Create the full file path by appending the desired file name
NSString *yourArrayFileName = [documentsDirectory stringByAppendingPathComponent:@"example.dat"];
//Load the array
NSMutableArray *yourArray = [[NSMutableArray alloc] initWithContentsOfFile: yourArrayFileName];
if(yourArray == nil)
pragma mark - Orientation stuff
-(BOOL)shouldAutorotate
{
if (isIpadIdiom) {
return YES;
}
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
CellSize size;
if (_list) {
size = CellSizeList;
}
else{
//TODO: Factorize landscape/portrait code
//Randomize cell size and avoid hole
if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation])) {
if (_currentRowStatus == CellRowEmpty ||
_currentRowStatus == CellRowOneSpaceUsed) {