This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) $ sudo gem install cocoapods (gem will get installed in Ruby inside System library) | |
2) create a xcode project | |
3) Open terminal | |
4) cd "$ path to your project root directory" | |
5) $ touch podfile | |
6) open -e podfile | |
7) pod 'AFNetworking', '0.9.1' (Cocoapods Podfile name ) | |
8) pod install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( NSClassFromString(@"UIAlertController") != nil ) { | |
//make and use a UIAlertController | |
UIAlertController *alertController = [UIAlertController | |
alertControllerWithTitle:@"Вы не авторизованы" | |
message:@"Пожалуйста введите логин и пароль" | |
preferredStyle:UIAlertControllerStyleAlert]; | |
UIAlertAction *okAction = [UIAlertAction | |
actionWithTitle:@"OK" | |
style:UIAlertActionStyleDefault | |
handler:^(UIAlertAction *action) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *)imageByCroppingImage:(UIImage *)image toSize:(CGSize)size | |
{ | |
// not equivalent to image.size (which depends on the imageOrientation)! | |
double refWidth = CGImageGetWidth(image.CGImage); | |
double refHeight = CGImageGetHeight(image.CGImage); | |
double x = (refWidth - size.width) / 2.0; | |
double y = (refHeight - size.height) / 2.0; | |
CGRect cropRect = CGRectMake(x, y, size.height, size.width); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// Override point for customization after application launch. | |
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 | |
[[UIApplication sharedApplication] registerUserNotificationSettings: | |
[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) | |
categories:nil]]; | |
[[UIApplication sharedApplication] registerForRemoteNotifications]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:[[NSBundle mainBundle].infoDictionary objectForKey:@"UIMainStoryboardFile"] bundle:[NSBundle mainBundle]]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; | |
MyViewController *controller =[storyboard instantiateViewControllerWithIdentifier:@"myViewController"]; | |
MyNavigationController* nav = [[MyNavigationController alloc] initWithRootViewController:controller]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) | |
#else | |
# define DLog(...) | |
#endif | |
// ALog always displays output regardless of the DEBUG setting | |
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/sysctl.h> | |
- (NSString *)platform | |
{ | |
int mib[2]; | |
size_t len; | |
char *machine; | |
mib[0] = CTL_HW; | |
mib[1] = HW_MACHINE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <CoreTelephony/CTTelephonyNetworkInfo.h> | |
#import "Reachability.h" | |
@implementation DeviceInfo | |
- (NSString *)getNetworkType | |
{ | |
Reachability *reachability = [Reachability reachabilityForInternetConnection]; | |
[reachability startNotifier]; | |
NewerOlder