I used the following code and i have a couple of issues with itint SomeInts = [1,2,3,4,5,6,7,8,9,10]func reverseOrderFunc(num1:Int,num2,Int)->Bool{if num1<num2{return false}return true}sort(SomeInts,reverseOrderFunc)1.) why do we return bool2.) xcode playground displays an error in the sort statement that it cannot invoke argument list of type ([Int],Int,Int)->BoolKindly help me out of this confusionRegards,Navjot
Search results for
SwiftUI List performance
50,616 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
The code you posted isn't even correct syntax. Presumably you meant this:let SomeInts = [1,2,3,4,5,6,7,8,9,10] func reverseOrderFunc(num1:Int,num2:Int)->Bool{ if num1<num2 { return false } return true } sort(SomeInts,reverseOrderFunc)>> 1.) why do we return boolBecause the closure you're passing to 'sort' is supposed to say whether one number comes before another: true/false. So, a Bool.>> 2.) xcode playground displays an error in the sort statement that it cannot invoke argument list of type ([Int],Int,Int)->BoolBecause in Swift 2, 'sort' is no longer a global function, so now you invoke it like this:SomeInts.sort (reverseOrderFunc)Note that in this case, you can just write:SomeInts.sort (>)because the > operator provides the test you need.
Topic:
Programming Languages
SubTopic:
Swift
Tags:
I have distributed my application for a single fee when downloaded. I need upgrade my app for 2 ways of distribution: 1) A single fee for a non-consumable subscription. All previously purchased apps must be in this group. 2) An auto-renewable subscription on a monthly basisWhat is the best way to perform these updates to an already distributed app?
You establish a relationship between two entities, an Address entity and a Room entity, by doing the following things:Get a reference to the addressGet a reference to the roomCalling [room setValue: address forKey: @name of address relationship];As the user enters an address on the address form, you're going to be performing fetches to locate matching addresses. You're probably going to want to display those addresses in a picker, table view, or collection view. Once the user has a selected address, you'll have the address reference.I assume your purpose for entering the rooms is that you're going to be creating and/or editing room instances for the user.I'd say, after working with CoreData and sqlite on different projects, there's an even chance that trying to think about how you'd do this in straight SQL is going to confuse you. It's all objects all the way down, you need to think about creating objects, setting properties, and allowing the user to select objects out of fetch results.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
I have a very large Swift project with approx 300 source files at present. Performing a clean build is very slow, it can take 5+ minutes sometimes. Incremental builds can be faster, but if I modify a class that is used and heavily integrated into the app, then you're looking at the same 5+ minutes even if I just change 1 line in those particular common class files.Does anyone have any suggestions how we can speed up build times?We have a fair few singleton manager classes that are heavily used, would perhaps creating a framework for these be advised?Any suggestions welcome!
And what's so bad about that? All Swift features and performance benefits are all still there. In fact, it's not much different at all, since the Swift runtime is based on the ObjC runtime to begin with. The only differences with an @objc class are that 1) you can optionally access non-private methods dynamically (although Swift callers will still use its usual vtable method), and 2) you can optionally mark things as requiring dynamic dispatch, so that they work with things like KVO and Core Data. Both of these are features that I wish the native Swift runtime had anyway; Swift has a lot of good ideas, but it's also done a good deal of throwing out the baby with the bathwater when it comes to ObjC's dynamic features.
Topic:
Programming Languages
SubTopic:
Swift
Tags:
What keys/dictionaries did you use to disable ATS for localhost only? I've tried various combinations of the exceptions listed in the tech notes and haven't had any success.I'll file a radar requesting that localhost be excempted by default from ATS... or at least allow a specific key to deal with it specifically.
Topic:
App & System Services
SubTopic:
Networking
Tags:
You can get some crash reports directly from Xcode. Open the Organizer, select your archive from the list and select the Crashes tab. Though this only gives you a small sample of the crash reports your user might be experiencing. There are 3rd party frameworks that do this much better, and let users fill in an email address or notes about the crash. I use HockeyApp, and it works well for me. You can search for others like this.
Topic:
UI Frameworks
SubTopic:
AppKit
Tags:
Good questions. I don't have a definitive list of which of the many attributes actually get indexed, I'll try to get some clarification around that. You definitely would not want to do separate items for each word-token. What you'd want to do is have an item entry associated with each note (or whatever reasonably high level notion of a document that would make sense for your app). Presumably you'd put the contents of the note into the textContent property. In a quick test that appears to be getting indexed.
Topic:
App & System Services
SubTopic:
General
Tags:
I'm trying to convert the sample app AVMetadataRecordPlay from Objective C:NSArray *specs = @[@{ (__bridge id)kCMMetadataFormatDescriptionMetadataSpecificationKey_Identifier : AVMetadataIdentifierQuickTimeMetadataLocationISO6709, (__bridge id)kCMMetadataFormatDescriptionMetadataSpecificationKey_DataType : (__bridge id)kCMMetadataDataType_QuickTimeMetadataLocation_ISO6709 }]; CMFormatDescriptionRef locationMetadataDesc = NULL; CMMetadataFormatDescriptionCreateWithMetadataSpecifications(kCFAllocatorDefault, kCMMetadataFormatType_Boxed, (__bridge CFArrayRef)specs, &locationMetadataDesc);to Swift 2:let specs = [[kCMMetadataFormatDescriptionMetadataSpecificationKey_Identifier as String: AVMetadataIdentifierQuickTimeMetadataLocationISO6709, kCMMetadataFormatDescriptionMetadataSpecificationKey_DataType as String: kCMMetadataDataType_QuickTimeMetadataLocation_ISO6709 as String]] var locationMetadataDesc : CMFormatDescription CMMetadataFormatDescriptionCreateWithMetadataSpecifications(kCFAllocatorDefault, kCMMetad
I'm an OS X developer, but I think I can help you since Auto Layout works basically the same way on both platforms. It's perfectly fine to modify constraints anywhere (except in layout() or any similar methods that actually do the layout work). For example, I like to modify constraints in my action methods (you know, like swapping out detail views when the setting of a pop-up button is changed) or in my animation context completion handlers. Or, if you really want to use updateConstraints, just call self.needsUpdateConstraints = true and updateConstraints will be called at the end of the run loop cycle. (This is great for performance because you can set the needsUpdateConstraints as many times as you wish and the actual work will only happen once.)
Topic:
UI Frameworks
SubTopic:
UIKit
Tags:
Unfortunately I cannot confirm this. On my Mac with 10.10.4 (14E46) in the iCloud settings I see the bar at the bottom and it says 6,63 GB used for backups. When I click on Manage I see a lot apps with the used memory but Backups is at the end of the list with 0KB. In the right-hand pane there is no backup I can delete.
Topic:
App & System Services
SubTopic:
Core OS
Tags:
On OS X Yosemite (10.10), is there any way to remove the enabled/disabled override setting for a launchd service?For example, to permanently disable non-existent service 'test' for root, do this:sudo launchctl disable user/0/testCheck that it has been added to the disabled list:sudo launchctl print-disabled user/0Result:disabled services = { test => true } login item associations = { }Now, how can I delete test from the disabled services list?(I know I can enable it, but I just want to remove the entry entirely.)Note:If I reboot my computer, I see that the 'test' override has been added to a launchd disabled file:sudo cat /var/db/com.apple.xpc.launchd/disabled.0.plistResult:<?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd> <plist version=1.0> <dict> <key>test</key> <true/> </dict> </plist>I have tried running this command to manually delete it from the .plist fi
An AVPlayer instance has the following methods that would be useful:func currentTime() -> CMTimefunc seekToTime(time: CMTime)If you command-double-click on 'AVPlayer' in your source, it will bring up the generated Swift interface from the header file for AVPlayer, which will list the available methods with basic documentation.(And command-double-clicking on CMTime in the AVPlayer header or in your code will likewise bring up the generated Swift interface for CMTime...)
Topic:
Programming Languages
SubTopic:
Swift
Tags:
Hi everyone,Is there a way to open the Apple Health App from my app. I expected there to be a way using UIApplication's openURL: method, but didn't find Health app in the list of eligible targets.Any suggestions?Best regards,N