Tag: ios

How to parse a JSON file in swift?

I have a JSON file, want to parse and use list of objects in table view. Can any one share the code to parse JSON file in swift.

UIAlertController custom font, size, color

I am using new UIAlertController for showing alerts. I have this code: // nil titles break alert interface on iOS 8.0, so we’ll be using empty strings UIAlertController *alert = [UIAlertController alertControllerWithTitle: title == nil ? @””: title message: message preferredStyle: UIAlertControllerStyleAlert]; UIAlertAction *defaultAction = [UIAlertAction actionWithTitle: cancelButtonTitle style: UIAlertActionStyleCancel handler: nil]; [alert addAction: defaultAction]; […]

Swift language NSClassFromString

How to achieve reflection in Swift Language? How can I instantiate a class [[NSClassFromString(@”Foo”) alloc] init];

Animation stop after pushing view controller

I have label that animated slowly in single line, it appear like ticker. Everything work’s fine on current controller, but when we push navigation controller and then pop it, then animation stoped. I want it to continue from same position when it was stopped. There is it (code that launch ticker): float duration = (labelsContainer.frame.size.width […]

Is it possible to send PushNotifications, using Firebase Cloud Messaging (FCM) to special UDID, directly from device?

I am thinking about keeping all registration ids(push token) in DB and sending notifications to user from iPhone. I tried something like this but did not get any notification. func sendPNMessage() { FIRMessaging.messaging().sendMessage( [“body”: “hey”], to: TOKEN_ID, withMessageID: “1”, timeToLive: 108) } What I am doing wrong or maybe it is impossible at all?

Not getting Completed event on RxSwift with RxMoya

The following code works: let provider = RxMoyaProvider<MyAPI>( stubClosure: MoyaProvider.delayedStub(3)) provider .request(.studentSearch(query: “”)) .retry(3) .observeOn(MainScheduler.instance) .asObservable() .mapJSON() .map { respJSON in guard let studentsJsonArray = JSON(respJSON)[“students”].array else { throw APIError.wrongJSONParsing } return studentsJsonArray.map { guard let students = Student.fromJSON($0) else { fatalError(“Invalid Student Object”) } return students } as [Student] } .subscribe(onNext: { print($0) }, […]

Synthesized property and variable with underscore prefix: what does this mean?

Possible Duplicate: Underscore prefix on property name? What does this mean? @synthesize window=_window; I know that in general it means that ‘some class’ has a window, but why use _window instead of just window? Is this a namespace thing?

How can I debug 'unrecognized selector sent to instance' error

I am creating a custom table cell view for my table view. After I connect an image view of custom cell (in storyboard) to my code in swift, I get the following error. [UITableViewCellContentView image]: unrecognized selector sent to instance 0x7fb4fad7fd20′ *** First throw call stack: ( 0 CoreFoundation 0x000000010ccbb3f5 __exceptionPreprocess + 165 1 libobjc.A.dylib […]

UILabel text margin

I’m looking to set the left inset/margin of a UILabel and can’t find a method to do so. The label has a background set so just changing its origin won’t do the trick. It would be ideal to inset the text by 10px or so on the left hand side.

Objective-C and Swift URL encoding

I have a NSString like this: http://www. but I want to transform it to: http%3A%2F%2Fwww. How can I do this?