[Solved] Return from initializer without initializing all stored properties error

The error says you returned from init without initializing all stored properties. That’s what the problem is. You need to initialize Type and OperatingSystem in init: init () { DeviceID = 1233 Type = .Phone Operating_System = OperatingSystem(type: .iOS, version: OperatingSystemVersion(Major: 9, Minor: 0, Patch: 2)) UserID = 2 Description = “took” InventoryNR = “no17” … Read more

[Solved] How I could access to the Url of photo saved in the camera roll

Your question is extremely vague with nothing for us to work with. But in any case, I just created an app requiring that logic so I would just share with you func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { // Clear data if picture is repicked imageLocalURL = nil imageData = nil imageSelected = … Read more

[Solved] Why does my App lags when scrolling UICollectionView (Swift)? [closed]

For the future, it is better to post the relevant code here rather than post an image of all the code. You can start off with changing the cellForItemAtIndexPath implementation. You are downloading the image in the method (as a synchronous implementation). So unless the image is downloaded by contentsOfURL: and rendered, the cell won’t … Read more

[Solved] Login form in swift

If you have setup your segue in Storyboard, give the segue an identifier. (say , yourID) Then invoke the following method. self.performSegueWithIdentifier(“yourId”, sender: self) when you want to go to the next ViewController. EDIT call the method in last else. }else { self.actInd.startAnimating() var newUser = PFUser() newUser.username = username newUser.password = password newUser.email = … Read more

[Solved] Share Data Between View Controller and Container View

You are on the right track to setup the delegate. In Storyboard: create a Segue of type Embed Segue from the ContainerView to the ViewController to embed. Select the segue and set a Identifier. In Code, in prepareForSegue(): Set the myContainerView propert Set the delegate class ViewController: UITableViewController, ContainerViewDelegate { var myContainerView:ContainerView? // we do … Read more

[Solved] Create a comparison in an array

import Foundation let serverOutput = Data(“”” [ { “language”: “French”, “number”: “12” }, { “language”: “English”, “number”: “10” } ] “””.utf8) struct LangueUsers: Codable { let language: String let number: Int enum CodingKeys: CodingKey { case language case number } init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) language = try container.decode(String.self, … Read more

[Solved] Binary operator ‘

The error is pretty clear. numOfPrecentile is a UILabel?. You can’t compare that to a Double. I would suggest storing your calculation into a Double first before setting numOfPercentile.text. @objc func calculate() { if let yourHeightTxtField = yourHeightTxtField.text, let yourWeightTxtField = yourWeightTxtField.text { if let height = Double(yourHeightTxtField), let weight = Double(yourWeightTxtField) { view.endEditing(true) percentile.isHidden … Read more

[Solved] How to make this HTTP Post request using alamofire? [closed]

let url = “192.168.1.1/api/project” var header = [String:String]() header[“accept”] = “aplication/json” header[“key”] = “David” let reqParam = [“project”:[“title”:”Test Title”,”description”:”Test description for new project”,”priority”:false,”category_id”:1,”location_id”:1]] Alamofire.upload(multipartFormData: { multipartFormData in for (key, value) in reqParam{ do{ let data = try JSONSerialization.data(withJSONObject: value, options: .prettyPrinted) multipartFormData.append(data, withName: key) }catch(let err){ print(err.localizedDescription) } } },usingThreshold:UInt64.init(), to: url, method: .post, headers: … Read more

[Solved] How do you find something in a dictionary without knowing the name of the dictionary

// A good, more object oriented way- struct Fruit{ var name: String var cost: Double var nutrition: Int } let fruitsDataHolder = [ Fruit(name: “Apple”, cost: 10.0, nutrition: 5), Fruit(name: “Banana”, cost: 15.0, nutrition: 10) ] func getFruitsCost(fruits: [Fruit]) -> Double{ var totalCost = 0.0 for fruit in fruits{ totalCost += fruit.cost } return totalCost … Read more

[Solved] Post request in swift with encodable [closed]

This JSON is wrong. You JSON must be valid. In order to make above JSON valid we need to set array with a key. Wrong { [{ “time”: 1, “score”: 20, “status”: true, “answer”: 456 }], challenge_date”: “2019-03-13” } Correct { “array”: [{ “time”: 1, “score”: 20, “status”: true, “answer”: 456 }], “challenge_date”: “2019-03-13” } … Read more

[Solved] How can I compare the current time with a specific time?

Don’t use a label to hold information. Save the date at the moment you set your label’s text, as a Date, into your model (or simply as a property in your view controller.) Then, when you need to tell If the “label time” is before or after 4:00PM, use the Calendar method date(bySettingHour:minute:second:of:matchingPolicy:repeatedTimePolicy:direction:) to generate … Read more