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 UIKit | |
class ExpandableObject { | |
public var subItems = [ExpandableObject]() | |
public var title: String? | |
public var isExpanded: Bool = false | |
public var isChild: Bool = false | |
public var cellIdentifier: String? | |
public var canExpand: Bool { |
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
- (IBAction)addPhotoTap:(id)sender { | |
UIAlertController* alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; | |
UIAlertAction* fromGallery = [UIAlertAction actionWithTitle:@"Загрузить из фотоальбома" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { | |
UIImagePickerController * picker = [[UIImagePickerController alloc] init]; | |
picker.delegate = self; | |
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; |
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
#pragma mark - UIScrolViewDelegate | |
- (void)scrollViewDidScroll:(UIScrollView *)scrollView | |
{ | |
CGFloat pageWidth = scrollView.frame.size.width; | |
float fractionalPage = scrollView.contentOffset.x / pageWidth; | |
NSInteger page = lround(fractionalPage); | |
if (page == 0) { |
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 __IPHONE_OS_VERSION_MAX_ALLOWED > 80000 | |
//ios 9+ | |
CNContactStore *store = [[CNContactStore alloc] init]; | |
[store requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * _Nullable error) { | |
if (granted == YES) { | |
NSMutableArray *contacts = [NSMutableArray new]; | |
NSArray *keys = @[CNContactFamilyNameKey, CNContactGivenNameKey, CNContactPhoneNumbersKey, CNContactImageDataKey]; | |
NSString *containerId = store.defaultContainerIdentifier; | |
NSPredicate *predicate = [CNContact predicateForContactsInContainerWithIdentifier:containerId]; | |
NSError *error; |
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 <ifaddrs.h> | |
#include <arpa/inet.h> | |
#pragma mark - Get Ip Address | |
- (NSString *)getIpAddress | |
{ | |
NSString *address = @"error"; | |
struct ifaddrs *interfaces = NULL; | |
struct ifaddrs *temp_addr = NULL; |
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
// | |
// XmppManager.h | |
// | |
// | |
// | |
#import <Foundation/Foundation.h> | |
@protocol XmppChatDelegate <NSObject> | |
- (void)didReceiveMessage:(NSDictionary *)msgDict; |
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
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"ru_RU"]; | |
[dateFormatter setLocale:locale]; | |
[dateFormatter setDateStyle:NSDateFormatterLongStyle]; | |
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle]; | |
dateFormatter.doesRelativeDateFormatting = YES; | |
_dateAsString = [dateFormatter stringFromDate:_date]; |
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
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"thisIsTheNameOfYourDateProperty" ascending:NO]; | |
NSArray *orderedArray = [arrayOfCustomObjects sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]]; |
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
NSTimeInterval today = [[NSDate date] timeIntervalSince1970]; | |
NSString *intervalString = [NSString stringWithFormat:@"%f", today]; | |
NSDate *date = [NSDate dateWithTimeIntervalSince1970:[intervalString doubleValue]]; | |
NSDateFormatter *formatter=[[NSDateFormatter alloc]init]; | |
[formatter setDateFormat:@"yyyyMMddhhmm"]; | |
NSString *strValue = [formatter stringFromDate:date]; |
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
_textField.delegate = self (UITextFieldDelegate) | |
- (NSMutableString *)filteredPhoneStringFromString:(NSString *)string withFilter:(NSString *)filter | |
{ | |
NSUInteger onOriginal = 0, onFilter = 0, onOutput = 0; | |
char outputString[([filter length])]; | |
BOOL done = NO; | |
while(onFilter < [filter length] && !done) | |
{ |
NewerOlder