swift3

How to run multiple background thread tasks one at a time?

烂漫一生 提交于 2019-12-14 03:52:23
问题 I'm trying to loop through an array of String objects containing dates of the month October 2016, which means 31 String objects: 1 October 2016...31 October 2016. For each object I want to retrieve some data from the database and append the returned value (also a String object) to a new array. The tricky part, though, is that the new array of String objects should be in the exact same order as the dates array. So for example, the 5th object in the new array should be the returned value of the

Cannot use instance member 'getA' within property initializer; property initializers run before 'self' is available [duplicate]

妖精的绣舞 提交于 2019-12-14 03:49:58
问题 This question already has answers here : How to initialize properties that depend on each other (4 answers) Closed last year . Y this giving this error - Cannot use instance member 'getA' within property initializer; property initializers run before 'self' is available class A { var asd : String = getA() func getA() -> String { return "A" } } 回答1: Property initializer run before self is available. The solution is to lazy initialize the property: class A { lazy var asd: String = getA() func

Swift 3 / Alamofire: Cant load the table with the data

僤鯓⒐⒋嵵緔 提交于 2019-12-14 03:49:13
问题 I am trying to load the data on the UItableview, I am able to see the records fetched in the output panel but not able to fetch them on the UItableview. Please find the code below: import UIKit import Alamofire import SwiftyJSON class CategoryViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, NSURLConnectionDelegate { var tableData = Array<Category>() var arrRes = [[String:AnyObject]]() //Array of dictionary var category = [Category]() var catTitle = "" var id = ""

In iOS, how to change launchscreen image according environment (dev, hom, prod)?

谁都会走 提交于 2019-12-14 03:48:50
问题 I have a launchscreen with a image, so far working well. But now I have 3 schemas: dev, hom and prod. I would to know how to change the launch screen image according the schema selected at the build time? EDIT I have in mind two options, but I do not know which one is best: Option 1: Create two storyboards and create a variable to set the name of the correct storyboard in the app delegate. This variable I will use in the Info.plist key (Launch screen interface file base name). Option 2:

Swift 3 & iOS 10 false memory leak bug

北战南征 提交于 2019-12-14 03:46:09
问题 There seems to be a (false) memory leak bug in Xcode 8 when using with iOS 10 & Swift 3. The following code reports a memory leak in Instruments and the Xcode 8 memory debugger: class SomeClass: NSObject { var view: SomeView! deinit { print("SomeClass deinit") } } class SomeView: UIView { weak var reference: SomeClass? deinit { print("SomeView deinit") } } class ViewController: UIViewController { var someProperty: SomeClass? override func viewDidLoad() { super.viewDidLoad() let c = SomeClass(

Issue while merging Video & Audio iOS swift4

余生颓废 提交于 2019-12-14 03:25:44
问题 2019-04-10 10:49:51.590008+0500 VTKaraokeView[869:1039603] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray' Hi iOS Gurus! I'm merging Video & Audio files(.mp4 & .mp3 file)... BACKGROUND & PROBLEM STATEMENT:- As I'm working on an App like karaoke... I'm recording Video with Background Music and then AFTER MERGING this recorded video & background music into new newVideo.mp4 file and then Playing

Terminating App due to 'Swift._NSContiguousString' to 'PFObject'

空扰寡人 提交于 2019-12-14 03:21:29
问题 I'm Stuck on this issue and I have tried different 'fixes' for this issue however nothing seems to work. Code for Ref: class FindAParty:UITableViewController{ var partyData:NSMutableArray! = NSMutableArray() //var user:NSMutableArray = NSMutableArray() override init(style: UITableViewStyle){ super.init(style: style) } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) //fatalError("init(coder:) has not been implemented") } @IBAction func loadData(){ print ("Load Data went

How do I toggle between UIWindows?

爷,独闯天下 提交于 2019-12-14 03:06:30
问题 Scenario: I've created an overlay window (with tag = 100) that I eventually want to dismiss. But the following code doesn't work: UIApplication.shared.windows.first?.becomeKey() UIApplication.shared.windows.last?.resignKey() (lldb) po UIApplication.shared.windows ▿ 2 elements - 0 : <UIWindow: 0x7fa698d0ad00; frame = (0 0; 768 1024); gestureRecognizers = <NSArray: 0x600000048550>; layer = <UIWindowLayer: 0x6000000278a0>> - 1 : <UIWindow: 0x7fa698d14bb0; frame = (0 0; 768 1024); autoresize = W

SWIFT 3 - CGImage copy always nil

不想你离开。 提交于 2019-12-14 02:28:23
问题 having this problem and trying to fix it for hours. func changeColorByTransparent(colorMasking : [CGFloat]) { UIGraphicsBeginImageContext(self.symbolImageView.frame.size) self.symbolImageView.layer.render(in: UIGraphicsGetCurrentContext()!) self.symbolImageView.image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() if let image = self.symbolImageView.image { print("image ok") if let cgimage = image.cgImage { print("cgimage ok") if let imageRef = cgimage.copy

Local notifications - repeat Interval in swift 3

无人久伴 提交于 2019-12-14 02:25:30
问题 I want to repeat local notification every week, before iOS10 there is repeatInterval , but i am not able to find anything suitable to repeat notifications in iOS10. TimeTrigger and calendarTrigger both have repeat as true or false, where can i apply repeat as weekly, daily, monthly. Thanks. 回答1: Try this. func scheduleNotification(at date: Date, body: String) { let triggerWeekly = Calendar.current.dateComponents([.weekday,hour,.minute,.second,], from: date) let trigger =