xcode9

ios UICollectionView cell selecting and deselecting issue

人盡茶涼 提交于 2021-01-28 08:23:04
问题 Im using UIcollection view as my tabbar when I scroll collection view horizontally previous selected cell will not deselect when i select new one this is my code to change colour when i select a cell and deselect a cell var selectedIndexPath : IndexPath = [] func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { if let cell = collectionView.cellForItem(at: indexPath) as? BottomCollectionViewCell { cell.contentView.backgroundColor = UIColor.orange cell

“ambiguous use” on generic method after migration to swift 4

若如初见. 提交于 2021-01-26 22:48:20
问题 I am trying to migrate my code from xcode 8.2 swift 3.0.2 to xcode 9 swift 4, and I have problem with this code: func test<T0, TRet>(_ fn: (T0) -> TRet) -> Void { print("foo1") print(T0.self) } func test<T0, T1, TRet>(_ fn: (T0, T1) -> TRet) -> Void { print("foo2") print(T0.self) print(T1.self) } let fn2 : (Int, Int) -> Int = { (x:Int, y:Int)->Int in return x+y } test(fn2) xcode 8.0.2, swift 3.0.2 results with: foo2 Int Int xcode 9, swift 4 results with: Playground execution failed: error:

“ambiguous use” on generic method after migration to swift 4

点点圈 提交于 2021-01-26 22:47:43
问题 I am trying to migrate my code from xcode 8.2 swift 3.0.2 to xcode 9 swift 4, and I have problem with this code: func test<T0, TRet>(_ fn: (T0) -> TRet) -> Void { print("foo1") print(T0.self) } func test<T0, T1, TRet>(_ fn: (T0, T1) -> TRet) -> Void { print("foo2") print(T0.self) print(T1.self) } let fn2 : (Int, Int) -> Int = { (x:Int, y:Int)->Int in return x+y } test(fn2) xcode 8.0.2, swift 3.0.2 results with: foo2 Int Int xcode 9, swift 4 results with: Playground execution failed: error:

How do I prevent my macOS app from having multiple instances running at the same time?

安稳与你 提交于 2020-07-09 06:46:34
问题 I have an app for which I allow the user to enable 'open at login' via a preference using a launcher app (see https://en.atjason.com/Cocoa/SwiftCocoa_Auto%20Launch%20at%20Login.html). However, when I check the box to enable it, the launcher app opens another instance of my app. 回答1: I found a bundle key that can be used for this: LSMultipleInstancesProhibited . When set to YES , another instance cannot be opened. Potential downside is that it also prohibits another logged-in user from opening