Skip to content

Instantly share code, notes, and snippets.

View yabenatti's full-sized avatar

Yasmin Benatti yabenatti

  • Sweden
View GitHub Profile
@yabenatti
yabenatti / ProgramaticConstraints.m
Last active June 15, 2017 13:49
Programatic Constraints
- (void)setProgramaticConstraints {
self.myView = [UIView new];
self.myView.translatesAutoresizingMaskIntoConstraints = NO;
[self.myView setBackgroundColor:COLOR_WHITE_SMOKE];
[self.view addSubview:self.myView];
[self.myView addConstraint:[NSLayoutConstraint constraintWithItem:self.myView
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:nil
@yabenatti
yabenatti / DevicesConstants.h
Last active June 15, 2017 13:50
Devices and iOS Versions Constants
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_4 (IS_IPHONE && ([[UIScreen mainScreen] bounds].size.height == 480.0) && ((IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale) || !IS_OS_8_OR_LATER))
#define IS_IPHONE_5 (IS_IPHONE && ([[UIScreen mainScreen] bounds].size.height == 568.0) && ((IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale) || !IS_OS_8_OR_LATER))
#define IS_STANDARD_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale)
#define IS_ZOOMED_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale > [UIScreen mainScreen].scale)
#define IS_STANDA
@yabenatti
yabenatti / ReusableView.h
Last active June 15, 2017 13:41
ReusableView
#import <UIKit/UIKit.h>
IB_DESIGNABLE //Reusable Views loaded from a xib file, you can see them on storyboard
@interface ReusableView : UIView
@property (weak, nonatomic) IBOutlet UILabel *message;
@end
@yabenatti
yabenatti / NetworkManager.h
Last active June 14, 2017 21:57
NetworkManager for AFNetworking
#import <Foundation/Foundation.h>
@interface NetworkManager : NSObject
+(NetworkManager*) sharedInstance;
-(void)callAPIWithParameters:(NSDictionary *)parameters andUrl:(NSString *)url andMethodType:(NSString *)methodType andCompletion:(void(^) (BOOL success, id response, NSString *message, NSError *error)) completion;
@end
@yabenatti
yabenatti / ReusableTableCell.h
Created June 15, 2017 13:44
Reusable TableViewCell
#import <UIKit/UIKit.h>
static NSString * const reusableCellIdentifier = @"reusableCell";
@interface ReusableTableCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *reusableImageView;
@property (weak, nonatomic) IBOutlet UILabel *reusableLabel;
@end
@yabenatti
yabenatti / AccessTokenAdapter.swift
Last active July 11, 2017 12:48
Alamofire Manager
import Foundation
import Alamofire
class AccessTokenAdapter: RequestAdapter {
private let accessToken: String
init(accessToken: String) {
self.accessToken = accessToken
}
@yabenatti
yabenatti / SaveUserDefault.m
Created June 20, 2017 11:53
Saving content to UserDefault
#pragma mark - User Defaults
//Saves information on cache
+ (void)saveToUserDefault:(NSObject*)objectToSave withKey:(NSString*)key {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:objectToSave forKey:key];
[userDefaults synchronize];
}
//Retrieves information from cache
@yabenatti
yabenatti / .txt
Created August 23, 2017 17:40
App Delegate Methods When Opening the App
DELEGATE METHODS CALLED WHEN OPENING APP
Opening app when system killed or user killed
didFinishLaunchingWithOptions
applicationDidBecomeActive
Opening app when backgrounded
applicationWillEnterForeground
applicationDidBecomeActive
@yabenatti
yabenatti / MiniCursoIFSPSwiftProperties.swift
Created November 9, 2017 23:59
MiniCursoIFSPSwiftProperties
let nonMutableProperty = "this content cannot change"
var mutableProperty = "this content can be changed"
mutableProperty = "changing variable content"
@yabenatti
yabenatti / MiniCursoIFSPSwiftOptionals.swift
Created November 10, 2017 00:19
MiniCursoIFSPSwiftOptionals
var optionalString: String? = nil
if let unwrappedOptionalWithIf = optionalString {
print("Use \(unwrappedOptionalWithIf) here")
}
func printString(string: String?) {
guard let unwrappedOptionalWithGuard = optionalString else {
print("Treat error")
return