Skip to content

Instantly share code, notes, and snippets.

Yasmin Benatti yabenatti

Block or report user

Report or block yabenatti

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yabenatti
yabenatti / NetworkManager.h
Last active Jun 14, 2017
NetworkManager for AFNetworking
View NetworkManager.h
#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
View ReusableView.h
#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 / ReusableTableCell.h
Created Jun 15, 2017
Reusable TableViewCell
View ReusableTableCell.h
#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 / ProgramaticConstraints.m
Last active Jun 15, 2017
Programatic Constraints
View ProgramaticConstraints.m
- (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 Jun 15, 2017
Devices and iOS Versions Constants
View DevicesConstants.h
#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 / SaveUserDefault.m
Created Jun 20, 2017
Saving content to UserDefault
View SaveUserDefault.m
#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
View AccessTokenAdapter.swift
import Foundation
import Alamofire
class AccessTokenAdapter: RequestAdapter {
private let accessToken: String
init(accessToken: String) {
self.accessToken = accessToken
}
@yabenatti
yabenatti / .txt
Created Aug 23, 2017
App Delegate Methods When Opening the App
View .txt
DELEGATE METHODS CALLED WHEN OPENING APP
Opening app when system killed or user killed
didFinishLaunchingWithOptions
applicationDidBecomeActive
Opening app when backgrounded
applicationWillEnterForeground
applicationDidBecomeActive
View MiniCursoIFSPSwiftProperties.swift
let nonMutableProperty = "this content cannot change"
var mutableProperty = "this content can be changed"
mutableProperty = "changing variable content"
View MiniCursoIFSPSwiftOptionals.swift
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
You can’t perform that action at this time.