Search results for

SwiftUI List performance

50,609 results found

Post

Replies

Boosts

Views

Activity

Apple watch os2 beta Battery Problems
I noticed a lot of people having problems with Watch os2 beta 2, today i decided to buy a second watch so i could use my first one for development. The new one is running OS1.01 and it is so much faster and the battery is running great. I hope apple addresses this problem and they will get a fix soon. The performance and experience needs to be much better when the public release will be finished!Anyone found a solution or a cause for this problem?
6
0
3.9k
Jun ’15
Reply to Swift Extensions with generic type paramters
As far as I know, you can write extensions with where clause for generic classes or structs.extension Array where T: CustomStringConvertible { func join(joiner: String) -> String { var result = var isFirst = true for elt in self { if !isFirst { result += joiner } result += elt.description isFirst = false } return result } } var arr = [1,2,3] arr.join(,) var arrPoint = [CGPointZero, CGPoint(x: 1, y: 2)] arrPoint.join(,) //error: cannot invoke 'join' with an argument list of type '(String)'But this is another problem.What I don't understand is your code doesn't work in the Playground of my Mac.I may be missing something, but I cannot find it...I got it, { } was just a placeholder and need to be replaced.validationRules.validateEach() { (valid, error) -> () in //... }In this case validationRules's type is [StringValidationRule] (Array of struct), not [StringValidationRuleType] (Array of protocol), so it works.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’15
Reply to Serializing generic structs
Thanks cwrindfuss, finally a sane answer from someone.I went ahead and saw the lecture. In case someone else wants to see the lecture, it is Lecture 5. Objective-C Compatibilty, Property List, Views.I paste the actual coding and decoding code here:var program: AnyObject { // guaranteed to be a PropertyList get { return opStack.map { $0.description } } set { if let opSymbols = newValue as? Array<String> { var newOpStack = [Op]() for opSymbol in opSymbols { if let op = knownOps[opSymbol] { newOpStack.append(op) } else if let operand = NSNumberFormatter().numberFromString(opSymbol)?.doubleValue { newOpStack.append(.Operand(operand)) } } opStack = newOpStack } } }The code encodes and decodes an array of Ops to and from Property Lists. Op is an enum.The coding to PropertyList occurs on line 3. The $0 parameter actually corresponds to an Op enum. The description computed property does the actual encoding of Op to PropertyList there.This will be a crucial point later, so I repeat this: encodi
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’15
Installing El Capitan on a USB Flash Drive
I have tried this several times just to make sure I was doing it correctly, and I always come up with the same bad result. This is a 2013 Mac Book Air:Installed the El Capitan installer on my Yosemite system from the App StoreFormatted a brand new 128gb flash drive as Mac OS Extended (Journaled) with a GUID Partition TableInstalled the Installer on the flash drive: sudo /Applications/Install OS X 10.11 Developer Beta.app/Contents/Resources/createinstallmedia --volume /Volumes/ElCapInstaller --applicationpath /Applications/Install OS X 10.11 Developer Beta.app --nointeractionEjected the flash driveReinserted the flash drive and booted from it using the Option keyThe installation onto the flash drive proceeded and worked up to the very last, when it said Less that one second remaining. It stayed there and never finished, never rebooted. I waited what I thought ws a long time.I was able to **** off the installation log. I do see some errors that I don't know what to do with. They seem to be communications relate
4
0
11k
Jun ’15
Reply to Is it possible to add struct initializer via protocol extension?
An initializer has to be a designated initializer or a convenience initializer. An convenience initializer is not allowed in non-class type[s]. A designated initializer has to [initialize] all stored properties, which it cannot do, since the protocol extension would have to know the list of properties in the struct, and it cannot know that.So I guess the answer is no.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’15
Reply to Swift 2: throwing errors in computed properties
TL;DR: properties reflect the current state of an object. If they cannot provide state they should return `nil`. Throwing is for functions that mutate state or perform some operation.IMO error handling in Swift 2 is (intended to be) for runtime errors. Querying a property when it is not yet valid is not a runtime error, it is a programmer error (they should have first checked if the Promise is pending before asking for its resolution status).Thus IMO, return an optional or change the property to be called something like state and return an enum for all states.With API design it is important to consider which is more readable:if let succeeded = promise.isSucceeded where succeeded { //… } // versus: do { if try promise.isSucceeded { } } catch Future.Pending { //… } // versus: if case .Succeeded = promise.state { //… }For me it's the final option.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’15
How do you contstrain types within tuples?
With Swift 2, you can write permute() as a method on Dictionary (assume that all keys and values are unique):extension Dictionary where Value: Hashable { func permute() -> [Value: Key] { var permuted = [Value: Key]() for (key, value) in self { permuted[value] = key } return permuted } }By permute, I mean specifically that keys become the values and vice versa.But what if you wanted to write this more generically so that any sequence of (key, value) tuples in which the values were hashable could be converted to a permuted dictionary. Is it possible?I'm thinking something like:extension SequenceType where Generator.Element: (Any, Hashable) { func permute() -> [Generator.Element.1: Generator.Element.0] { ... } }Or perhaps:extension SequenceType<Key, Value: Hashable> where Generator.Element == (Key, Value) { func permute() -> [Value: Key] { ... } }But these are both nonstarters. In the first version, it's not clear what Generator.Element: (Any, Hashable) would mean, and the compiler doesn't accept
4
0
723
Jun ’15
Reply to Apple's canOpenURL 'solution'
I use the canOpenURL to check which satnav apps a user has installed. As my app can then launch the users choice of satNav with the destination already set.I will have to use whitelists for that, but surely there are certain classes of apps that should be allowed to be queried. It's pointless me supporting every satnav app that I want to, then offer the user a list which will include several they don't have installed!
Topic: App & System Services SubTopic: Core OS Tags:
Jun ’15
Reply to What happens if the free CloudKit limit is reached?
I have another question: On the WWDC 2014 Keynote Apple said that there are different data transfer limits for assets and for database and every website I saw confirmed this. But when I look on the CloudKit Website (https://developer.apple.com/icloud/index.html) there is only one data transfer limit quoted which seems to include assets and databases. And when I look on the CloudKit dashboard there is also only one daat transfer limit listed. So has Apple merged both data transfer limits?
Jun ’15
Core Image: what are thread safety and optimal strategies for concurrency?
I have a few questions on Core Image, in relation to the new implementation in OS X 10.11.Can CIImages be considered thread-safe?In other words, can an identical or different CIContexts, on different threads, be accessing the same CIImage without running into problems?Are CIContexts themselves thread-safe? Even if they are, what would be the best strategy for higher performance: sharing a single CIContexts among threads that will concurrently use the context, or giving each thread its own CIContext to play with?
0
0
670
Jun ’15
Handoff and restoring view controller hierarchy
Good evening,I have been trying to implement handoff from my watchkit 1 extension to my iPhone app. The NSUserActivity creation works fine, the icon gets displayed on the iPhone's lock screen and my application delegate gets called with the proper activity/data.What I'm struggling with is to restore the required view controller hierarchy to resume the activity on the iPhone. I was expecting this to be as straightforward as UIKit state restoration, which I have recently implemented, but I keep hitting a wall.My app supports two activities for handoff right now: Activity A and Activity B.My view controller hierarchy is as follows:Root (UISplitViewController)1. primary (UINavigationController)index UITableViewController subindex UITableViewController details UITableViewController (see below)2. secondary (UINavigationController)details UITableViewController complete details UIViewControllerHere is my continueUserActivity function: func application(application: UIApplication, continueUserActivity userActivity: NSU
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
1.3k
Jun ’15
Reply to Equatable with two two-dimension array
After I posted my question, I saw yours in the suggestion list. I'm surprising we find the same issue, that is array with equatable elements can not be marked equatable though they can use ==.You can define as many as possible == for a few dimensions, but this is still limited. if you defiend == for two dimensions, what about three? If you defined == for three dimension, what about four?I tried many ways to solve this problem, but none of them can easily solve this problem, unless developer defined a new structure conform to SequenceType or ArrayType, maybe called EquatableArray<T: Equatable>.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’15
Reply to Writing / Reading Data Files in OS X
The best solution for you is probably the property list format (also known as plist), which uses XML to serialize (i.e. convert a network of objects into a single chunk of data) basic dictionary content. Stuff like strings, numbers, dates, or even raw data. Check out the NSPropertyListSerialization class for your reading and writing needs.To write to a file, you'd use code like this://Assume you've got an array or dictionary named informationlet data = try NSPropertyListSerialization.dataWithPropertyList(array, format:.XMLFormat_v1_0, options:0)data.writeToURL(/* your data file location */, atomically: false);To read from a file, you'd use code like this:let data = NSData(contentsOfURL:/ your data file location */ )let information = try NSPropertyListSerialization.propertyListWithData(data, options:0, format: nil)//Use the informationImportant: Remember that not everything can go into a property list. More complicated data like images and colors must be flattened into data first using the NS
Topic: UI Frameworks SubTopic: AppKit Tags:
Jun ’15