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
| http://www.theappguruz.com/blog/json-parsing-example-swift |
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)addAccessory:(HondaDataItem *)hondaDataItem withCompletion:(void(^)(BOOL success))completion failure:(void(^)(HondaFailureCode failureCode))failure{ | |
| PFObject *hondaItem = [PFObject objectWithClassName:@"HondaItem"]; | |
| hondaItem[@"groupAccessary"] = @"Điện"; | |
| hondaItem[@"nameItem"] = @"Đèn chiếu hậu sau"; | |
| hondaItem[@"description"] = @"Bổ xung"; | |
| hondaItem[@"renewPrice"] = @50000; | |
| hondaItem[@"fixedPrice"] = @10000; | |
| hondaItem[@"startDate"] = [NSDate date]; | |
| hondaItem[@"endDate"] = [NSDate date]; | |
| // Convert to JPEG with 50% quality |
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)getGroupAccessory:(NSString *)groupAccessoryName withCompletion:(void(^)(BOOL success))completion failure:(void(^)(HondaFailureCode failureCode))failure{ | |
| PFQuery *query = [PFQuery queryWithClassName:@"HondaItem"]; | |
| [query whereKey:@"groupAccessary" hasPrefix:@"Điện"]; | |
| [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { | |
| if (!error) { | |
| // The find succeeded. | |
| if ([self convertPFObjectToHondaDataItem:objects].count) { | |
| completion([self convertPFObjectToHondaDataItem:objects]); | |
| } | |
| } 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
| -(void)deleteAccessory:(HondaDataItem *)hondaDataItem withCompletion:(void(^)(BOOL success))completion failure:(void(^)(HondaFailureCode failureCode))failure{ | |
| PFObject *hondaItem = [PFObject objectWithClassName:@"HondaItem"]; | |
| hondaItem.objectId = hondaDataItem.objectId; | |
| // multi delete | |
| // [PFObject deleteAllInBackground:@[object1, object2, object3]]; | |
| [hondaItem deleteInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) { | |
| if (succeeded) { | |
| // The object has been saved. | |
| completion(succeeded); | |
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 Foundation | |
| import Alamofire | |
| public class ServiceManager { | |
| class var sharedInstance: ServiceManager { | |
| struct Static { | |
| static var onceToken: dispatch_once_t = 0 | |
| static var instance: ServiceManager? = nil | |
| } | |
| dispatch_once(&Static.onceToken) { |
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
| NSURL *url = [self fileToURL:self.documentName]; | |
| NSArray *objectsToShare = @[url]; | |
| AirDropActivityView *activityDownload = [[AirDropActivityView alloc] init]; | |
| activityDownload.airDropType = 0; | |
| AirDropActivityView *activityTrash = [[AirDropActivityView alloc] init]; | |
| activityTrash.airDropType = 1; | |
| AirDropActivityView *activityMove = [[AirDropActivityView alloc] init]; | |
| activityMove.airDropType = 2; |
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
| NSURL *url = [self fileToURL:self.documentName]; | |
| NSArray *objectsToShare = @[url]; | |
| AirDropActivityView *activityDownload = [[AirDropActivityView alloc] init]; | |
| activityDownload.airDropType = 0; | |
| AirDropActivityView *activityTrash = [[AirDropActivityView alloc] init]; | |
| activityTrash.airDropType = 1; | |
| AirDropActivityView *activityMove = [[AirDropActivityView alloc] init]; | |
| activityMove.airDropType = 2; |
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
| let values = [2.0,4.0,5.0,7.0] | |
| //Normal | |
| var squares: [Double] = [] | |
| for value in values { | |
| squares.append(value * value) | |
| } | |
| //Use map | |
| let mapSquare = values.map{$0 * 2} | |
| print(mapSquare) |
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
| let mapDetailSquare = values.map ({ (value:Double) -> Double in | |
| return value * 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
| let square = values.map {value in value * value} |
OlderNewer