|
Variable |
Type |
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 | |
| import CoreData | |
| import AVFoundation | |
| class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, VPDAODelegateProtocol, NSFetchedResultsControllerDelegate { | |
| @IBOutlet weak var segmentedControl: UISegmentedControl! | |
| @IBOutlet weak var tableView: UITableView! | |
| lazy var managedObjectContext : NSManagedObjectContext? = { |
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
| - (void) presentError:(NSError *)error { | |
| if ([[error domain] isEqualToString:NSURLErrorDomain]){ | |
| NSURL *failingURL = [[error userInfo] valueForKey:NSURLErrorFailingURLErrorKey]; | |
| switch ([error code]){ | |
| case NSURLErrorInternationalRoamingOff: | |
| case NSURLErrorCallIsActive: | |
| NSURLErrorDataNotAllowed: | |
| case NSURLErrorNotConnectedToInternet: | |
| [self beginObservingReachabilityStatusForHost:[failingURL host]]; |
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
| - (void) beginObservingReachabilityStatusForHost:(NSString *)host { | |
| SCNetworkReachabilityRef reachabilityRef = NULL; | |
| void (^callbackBlock)(SCNetworkReachabilityFlags) = ^(SCNetworkReachabilityFlags flags) { | |
| BOOL reachable = (flags & kSCNetworkReachabilityFlagsReachable) != 0; | |
| [[NSOperationQueue mainQueue] addOperationWithBlock:^{ | |
| [self host:host didBecomeReachable:reachable]; | |
| }]; | |
| }; | |
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
| - (void) host:(NSString *)__unused host didBecomeReachable:(BOOL)reachable { | |
| __strong UIButton *button = [self connectButton]; | |
| // Enable the button when we are notified the host became reachable | |
| [button setEnabled:reachable]; | |
| if (reachable){ | |
| [self endObservingReachabilityStatusForHost:nil]; | |
| } | |
| } |
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
| [[managedObject managedObjectContext] performBlock:^{ | |
| NSString *value = [managedObject someValue]; | |
| [NSOperationQueue mainQueue] addOperationWithBlock:^{ | |
| [[self label] setText:value]; | |
| }]; | |
| }]; |
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
| - (void) saveManagedObjectContext:(NSManagedObjectContext *)managedObjectContext withCompletion::(void (^)(BOOL, NSError *))completio{ | |
| managedObjectContext performBlock:^{ | |
| NSError *error = nil; | |
| if (![managedObjectContext save:&error]){ | |
| completion(NO, error); | |
| } else { | |
| if ([managedObjectContext parentContext] != nil){ | |
| [self saveManagedObjectContext:[managedObjectContext parentContext] withCompletion:completion]; | |
| } else { |
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
| [managedObjectContext performBlock:^{ | |
| NSError *error = nil; | |
| if (![managedObjectContext save:&error]){ | |
| [self handleError: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
| - (void) allPeopleInManagedObjectContext:(NSManagedObjectContext *)managedObjectContext withCompletion:(void (^)(NSArray*, NSError*))completion { | |
| [managedObjectContext performBlock:^{ | |
| NSError *error = nil; | |
| NSArray *results = nil; | |
| NSFetchRequest *fetchRequest = nil; | |
| NSPredicate *predicate = nil; | |
| NSEntityDescription *entity = nil; | |
| fetchRequest = [[NSFetchRequest alloc] init]; | |
| entity = [NSEntityDescription entityForName:@"Person" inManagedObjectContext:context]; |
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
| [cygnus:~/Desktop/SampleApp/SampleApp] quellish% clang -cc1 -analyzer-checker-help | |
| OVERVIEW: Clang Static Analyzer Checkers List | |
| USAGE: -analyzer-checker <CHECKER or PACKAGE,...> | |
| CHECKERS: | |
| alpha.core.BoolAssignment Warn about assigning non-{0,1} values to Boolean variables | |
| alpha.core.CastSize Check when casting a malloc'ed type T, whether the size is a multiple of the size of T | |
| alpha.core.CastToStruct Check for cast from non-struct pointer to struct pointer | |
| alpha.core.FixedAddr Check for assignment of a fixed address to a pointer |