This file contains 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
//@author http://stackoverflow.com/questions/5712527/how-to-detect-total-available-free-disk-space-on-the-iphone-ipad-device | |
- (uint64_t)freeDiskspace | |
{ | |
uint64_t totalSpace = 0; | |
uint64_t totalFreeSpace = 0; | |
NSError *error = nil; | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error]; |
This file contains 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
- (NSMutableArray*) yearCollections { | |
if(_yearCollections == nil) { | |
_yearCollections = [NSMutableArray new]; | |
// build year collection here | |
NSLog(@"building camera roll year collection tree."); | |
// 先設定好 取得phasset 參數 | |
PHImageManager* pim = (PHImageManager*) [PHImageManager defaultManager]; | |
PHImageRequestOptions* piro = [[PHImageRequestOptions alloc] init]; |
This file contains 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
@class MyClass ; | |
@protocol MyClassDelegate | |
@optional | |
- (void) myClassStatusChange:(MyClassStatusChangeRequest*) changeRequest; | |
@end |
This file contains 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
PHFetchResult* yearList = [PHCollectionList fetchMomentListsWithSubtype:PHCollectionListSubtypeMomentListYear options:nil]; | |
for(id foobar in yearList) { // each year | |
if([foobar isKindOfClass:[PHCollectionList class]]) { | |
PHCollectionList* yearCollectionList = (PHCollectionList*) foobar; | |
NSDateComponents* dateComps = [[NSCalendar currentCalendar] components:NSCalendarUnitYear fromDate:yearCollectionList.startDate]; | |
[years addObject: [NSNumber numberWithInt: (int) dateComps.year]]; | |
NSLog(@"year %d", dateComps.year); | |
PHFetchResult* momentCollectionList = [PHCollectionList fetchCollectionsInCollectionList:yearCollectionList options:nil]; |
This file contains 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
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ | |
NSLog(@"parameter1: %d parameter2: %f", parameter1, parameter2); | |
}); |
This file contains 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
[self.thumbnailView registerNib:[UINib nibWithNibName:@"___" bundle:nil] forCellWithReuseIdentifier:@"___"]; |
This file contains 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
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; | |
AFHTTPRequestSerializer * requestSerializer = [AFHTTPRequestSerializer serializer]; | |
AFHTTPResponseSerializer * responseSerializer = [AFHTTPResponseSerializer serializer]; | |
NSString *ua = @"Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"; | |
[requestSerializer setValue:ua forHTTPHeaderField:@"User-Agent"]; | |
// [requestSerializer setValue:@"application/xml" forHTTPHeaderField:@"Content-type"]; | |
responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/xml", nil]; | |
manager.responseSerializer = responseSerializer; | |
manager.requestSerializer = requestSerializer; |
This file contains 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 uitableview datasource and delegate | |
- (UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; | |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView; | |
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; | |
// optional | |
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; | |
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath; |
This file contains 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
UIGraphicsBeginImageContext(self.mjviewer.bounds.size); | |
[self.mjviewer.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage* currentMJpegImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
UIImageWriteToSavedPhotosAlbum(currentMJpegImage, nil, nil, nil); |
This file contains 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
CGRect screenBounds = [[UIScreen mainScreen] bounds]; | |
CGFloat screenScale = [[UIScreen mainScreen] scale]; | |
CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale); |