Trigger notification weekly Swift 3

You can set your trigger to repeat every monday at 1:05am as follow: import UserNotifications let trigger = UNCalendarNotificationTrigger(dateMatching: DateComponents(hour: 1, minute: 5, weekday: 2), repeats: true) print(trigger.nextTriggerDate() ?? “nil”) let content = UNMutableNotificationContent() content.title = “title” content.body = “body” // make sure you give each request a unique identifier. (nextTriggerDate description) let request = … Read more

Take a photo and save to photo library in Swift

Use below code for an image taken from Photo Gallery and save inside photo library. Code Support for Swift 3.1 & 4.0 version: First, we have to do the setup for Permissions inside Project’s .plist file:- 1) Camera <key>NSCameraUsageDescription</key> <string>This app will use camera.</string> 2) Photo Library <key>NSPhotoLibraryUsageDescription</key> <string>You can select photos to attach to … Read more

Alamofire 4 upload with parameters

Its working fine on my side. I’m using following code: let parameters = [ “file_name”: “swift_file.jpeg” ] Alamofire.upload(multipartFormData: { (multipartFormData) in multipartFormData.append(UIImageJPEGRepresentation(self.photoImageView.image!, 1)!, withName: “photo_path”, fileName: “swift_file.jpeg”, mimeType: “image/jpeg”) for (key, value) in parameters { multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key) } }, to:”http://sample.com/upload_img.php”) { (result) in switch result { case .success(let upload, _, _): upload.uploadProgress(closure: { … Read more

upload image to server using Alamofire

Try below code let image = UIImage.init(named: “myImage”) let imgData = UIImageJPEGRepresentation(image!, 0.2)! let parameters = [“name”: rname] //Optional for extra parameter Alamofire.upload(multipartFormData: { multipartFormData in multipartFormData.append(imgData, withName: “fileset”,fileName: “file.jpg”, mimeType: “image/jpg”) for (key, value) in parameters { multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key) } //Optional for extra parameters }, to:”mysite/upload.php”) { (result) in switch result { … Read more

UICollectionView Layout like SnapChat?

Based on a precedent answer adapted to your issue: -(id)initWithSize:(CGSize)size { self = [super init]; if (self) { _unitSize = CGSizeMake(size.width/2,80); _cellLayouts = [[NSMutableDictionary alloc] init]; } return self; } -(void)prepareLayout { for (NSInteger aSection = 0; aSection < [[self collectionView] numberOfSections]; aSection++) { //Create Cells Frames for (NSInteger aRow = 0; aRow < [[self … Read more

tech