Imagine you have a structure like:
[[String, String], [String, String], [String, String],]
and you need to replace a second value. How to do that?
Imagine you have a structure like:
[[String, String], [String, String], [String, String],]
and you need to replace a second value. How to do that?
At some point your app may need lot of supported languages, which sooner or later will come to common problem – each translation change requires app release via AppStore, which takes at least a day. Of course, there are many commercial solution, some pretty expensive. But is there any free way?
As you probably already know, sending push notification from Firebase will not display attached image on device. This example assumes you know how to configure push notifications in your app with Firebase. So let’s start.Continue reading
If you already upgraded XCode to newest 10.3 version, you may notice that opening XIBs created in older versions causes “Internal error” and UI elements are not visible. But there is simple solution for that. Continue reading
Imagine such case – you have list of messages, each one with timestamp. And you want to show them in the same way they arrived, with same timings. How to achieve this with RxSwift?Continue reading
Sooner or later, you will face the problem with object which are not deallocating. How to check if object gets deallocated? Just use deinit method like below:
deinit { print("I'm deallocating \(self)") }
If you won’t see such message when you think you class should be gone, the easiest way is to debug allocations. Because the most common reason for such behavior are strong references, you can print allocation counter this way:
print("ARC count \(CFGetRetainCount(self))")
But where to put this? First of all, in all you initialization methods. Just add some those prints after each few lines, and you should see where counter is growing. The same in cleanup methods, or if you dont have any, you can put this somewhere when your view controller is closing, like:
self.dismiss(animated: false) { print("VC is closing \(self.myobject)") }
And how to avoid strong references? The most common mistake, is using self in blocks, this is the place where you should use [unowned self], this way:
Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { [unowned self] (timer) in self.myobject.doSomething() })
What is “JavaScriptCore”? Well, it is a name for internal Safari javascript engine. Is it useful? For most of us it is not, but if you thinking about communicating between your Swift app and web page, it can be really useful.
Continue reading
This can be really painful when you just started with Swift. It really happens very often and can be confusing. Where it comes from?Continue reading
Getting “User interaction is not allowed” error in your build task? If yes, solution is very simple. Just login your build user (usually “jenkins”) via the GUI (which means VNC) and open Keychain Access. Select your signing private key, right-click, choose Get Info, change to the Access Control tab and select the “Allow all applications to access this item”.
Now error should be gone.
So you are trying to send instant message to parent iPhone app and still receiving “Payload could not be delivered”? This happens only if one of those two thing occured:
1. there is no connection to watch (you should check session.reachable in WCSession)
2. your iPhone app is not responding with didReceiveMessage:replyHandler:
Second one is the most probably so how to fix it? There are 2 “didReceiveMessage” methods in WCSessionDelegate protocol, to make it work, you need to implement second one:
- (void)session:(WCSession *)session didReceiveMessage:(NSDictionary*)message replyHandler:(void(^)(NSDictionary *replyMessage))replyHandler;
so just make it look like:
- (void)session:(WCSession *)session didReceiveMessage:(NSDictionary*)message replyHandler:(void(^)(NSDictionary *replyMessage))replyHandler { NSLog(@"iPhone: didReceiveMessage %@", message); replyHandler(@{@"command": @"reply"}); }
You just need to respond with NSDictionary. And it works. Really.