[Solved] Location Tracking bouncing the current location and by default drawing the route

CLLocationManager() has distanceFilter and pausesLocationUpdatesAutomatically. You can add a distanceFilter to “ignore” positions and set pausesLocationUpdatesAutomatically to true. If you are using location for navigation don’t hesitate to use kCLLocationAccuracyBestForNavigation 3 solved Location Tracking bouncing the current location and by default drawing the route

[Solved] How to convert ++ or — in Swift 3? [duplicate]

What you want IMHO @IBAction func didTapPreviousButton(_ sender: UIButton) { currentTrack -= 1 if currentTrack < 0 { currentTrack = (urlPlayerItems.count – 1) < 0 ? 0 : (urlPlayerItems.count – 1) } playTrack() } Correct replacing of POSTFIX as you have it (useless) @IBAction func didTapPreviousButton(_ sender: UIButton) { if currentTrack < 0 { currentTrack … Read more

[Solved] Parse complex json code

The problem is merely that your structs look nothing at all like your JSON! Your JSON is a dictionary whose keys have names like “-8802586561990153106-1804221538-5” and “8464567322535526441-1804221546-15”. But I don’t see you declaring any struct that deals with those keys. Then each of those turns out to be a dictionary with keys like “zug”, “ankunft”, … Read more

[Solved] Is HealthKit query on WatchOS limited?

The issue was that on iPhone HKHealthStore returns all records, however on watch only records added by release versions of the app are fetched. That’s why I didn’t see the same data on watch as on iPhone. solved Is HealthKit query on WatchOS limited?

[Solved] Objective – C to Swift : NSData with NSJSONSerialisation

Instead of JSONSerialization.jsonObject(with:) you are using NSKeyedUnarchiver, Also use native Data instead of NSData. var json = [AnyHashable:Any]() if let filePath = Bundle.main.path(forResource: “realstories”, ofType: “json”), let data = try? Data(contentsOf: URL(fileURLWithPath: filePath)), let dic = (try? JSONSerialization.jsonObject(with: data)) as? [AnyHashable:Any] { json = dic } solved Objective – C to Swift : NSData with … Read more

[Solved] Using the Swift Contacts Framework

I think it would be best to pull from the device’s Contacts, using the Contacts Framework – in Xcode this is the Contacts.framework package. The Apple site offers some sample code that you might be able to take advantage of in your application. For that you’d need permission from the user by enabling a NSContactsUsageDescription … Read more

[Solved] How to get minimum & maximum value in a NSString/String array?

@user3815344’s answer works, however you can simplify it by using minElement and maxElement to retrieve the minimum and maximum values. For example: let arr = [“55a”, “95a”, “66”, “25”, “88b”, “#”] let numbers: [Int] = arr.reduce([]) { if let num = “”.join($1.componentsSeparatedByCharactersInSet(NSCharacterSet.decimalDigitCharacterSet().invertedSet)).toInt() { return $0 + [num] } return $0 } minElement(numbers) // 25 maxElement(numbers) … Read more

[Solved] Populate CollectionView and TableView using objects at different index of same array [closed]

You can use filter method of array: //this filter will return you all objects whose group type is equal to 1 let collectionArray = (product_groups?.filter({$0.group_type == 1})) //this filter will return you all objects whose group type is equal to 2 let tableArray = (product_groups?.filter({$0.group_type == 2})) For group title to be section header: – … Read more

[Solved] Editor placeholder in source file swift [duplicate]

You need to write it like this: func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: “MenuCollectionViewCell”, for: indexPath) as! MenuCollectionViewCell return cell } 3 solved Editor placeholder in source file swift [duplicate]

[Solved] How to open Documents files of device programmatically in iOS [closed]

To open office files within an iOS app you can: 1- Use UIWebView . Here is a sample code with a document included in the app’s resources. NSString *path = [[NSBundle mainBundle] pathForResource:@”document” ofType:@”ppt”]; NSURL *url = [NSURL fileURLWithPath:path]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [self.webView loadRequest:request]; 2- You can use the QuickLook framework to preview … Read more

[Solved] Fibonacci in swift playground [duplicate]

The issue is that Int can only store 64bit numbers (on 64bit platforms) and Fibonacci 95 is bigger than the maximum number that can be stored on 64bits. Fibonacci 95 is 31 940 434 634 990 099 905, while the biggest number Int64 can hold is 2^63-1 = 9 223 372 036 854 775 807. … Read more