Objective-C: case insensitive file mapping

File names are case sensitive in iOS. That’s why it is important always to test your app containing file read/write operations not only in simulator, but also on the real iOS devices like iPad or iPhone. In particular situations you get a file name from some configuration file and wonder why NSFileManage cannot find it in the folder where it is contained. This can happen when the name of the file in configuration has a different case than the real file name. Such a special case can be handled by the function below:


+ (NSString*)findCaseInsensitiveFileMappinhForFile:(NSString*)file inFolder:(NSString*)folderPath
{
    
    NSString *result = nil;    
    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtURL:[NSURL fileURLWithPath:folderPath]
                                          includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey]
                                                             options:NSDirectoryEnumerationSkipsHiddenFiles
                                                        errorHandler:^BOOL(NSURL *url, NSError *error) {
        if (error) {
            NSLog(@"[Error] %@ (%@)", error, url);
            return NO;
        }
        
        return YES;
    }];
    
    for (NSURL *fileURL in enumerator) {
        NSString *filename;
        [fileURL getResourceValue:&filename forKey:NSURLNameKey error:nil];
        NSNumber *isDirectory;
        [fileURL getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:nil];
        
        // Find same file with different case
        if (![isDirectory boolValue]) {
            if ( [filename caseInsensitiveCompare:file] == NSOrderedSame) {               
                result = filename;
                break;
            }
        }
    }
    return result;
}


Cheat-sheets version 1.7

EN

The latest version 1.7 of the Cheat-sheets app is now available in iTunes App Store. It fixes app crashes while composing user feedback email on devices without preconfigured Mail app. This error was identified thanks to Fabric crash analytics tool, which was recently integrated into Cheet-sheets app. So far I made a really good experience with this tool.

Beside this the images for the AppStore have beed updated. Thus Cheat-sheets got a new glance in the virtual shop window of the App Store.

DE

Die letzte Version 1.7 der Spickzettel-App ist ab sofort bei iTunes verfügbar. In der neue Version wurde der Fehler behoben, bei dem die App abstürzte, wenn man versucht hatte User-Feedback zu verschicken und die Mail-App wurde dabei nicht konfiguriert. Diesen Fehler konnte dank dem Fabric Analytics-Tool identifiziert werden, welches seit kürzlich in der Cheat-sheets App integriert ist. Bis jetzt habe ich nur positive Erfahrung mit diesem Tool gemacht.

Außerdem wurden die Bilder für den AppStore erneuert. Jetzt braucht sich Cheat-sheets App nicht mehr im virtuellen Schaufenster des AppStores zu verstecken.

RU

Новую версию 1.7 мобильного приложения Шпаргалки можно теперь скачать в iTunes. В новой версии исправлена ошибка отправки отзыва на устройствах с не настроенным почтовым приложением. Эту ошибку удалось обнаружить и исправить благодаря аналитическим инструментам Fabriс, которые были не так давно встроены в приложение Шпаргалки.

Кроме этого были обновлены скриншоты пиложения Шпаргалки в магазине iTunes. Теперь Шпаргалки по-новому зaиграли в виртуальных витринах iTunes.

 

 

Tools for creating App Store images for iOS apps

While working on higher Impressions and views of the product page to increase the download number of my iOS app Cheat-sheets I started to deal with questions of ASO (App store optimization). App title, app description, key words are the things, that are comparably easy to set and to experiment with. But I faced a real problem with creating of good Screenshots / Images for the Cheat-sheets app.

I do realize, that App images in App store must be an eye catcher. They should attract ones attention and influence the user to push the download button. However, I’m not a designer and Photoshop is not my best friend. So I began to search for a free Screenshot generator tool. I though there might be much of them out there. But I was wrong.

First I tried Screenshot Maker at appinstitute.com. The screenshot generator has a modern intuitive interface. After uploading a screenshot it is possible to choose between particular templates, set the background color and the comment to the screenshot. Also, font and font size can be customized. Actually, it would be enough for my needs, if it worked properly. However, after exporting and downloading the generated images I was deeply disappointed. The font was set wrong and the text was on the wrong place. Beside this I noticed, that it is not possible to upload and to export images for iPad, although the option to upload iPad images is there… at least the button is displayed, which does not work. Above all is the absence of unicode support. Cheat-sheets is localized also in Russian. So, currently there is no way to make screenshots for it. Pity, very pity!

Next, I came across appscreenshot.me. It’s also a free screenshot generator. It has a pretty limited set of customization options and looks terrible 🙂 It’s not possible to design just a screenshot with a background. The uploaded image can be only embedded into iPhone frame. Screenshots for iPad cannot be designed with this generator at all. You cannot set colors as hexadecimal value, but only pick them from the color palette. For example, if you have 3 screenshots and one of them you would like update later, you’ll have to update all the 3 images, because otherwise the will look different. And at last unicode support… no unicode support, only latin letters! No commas, no spaces, no other symbols – only letters. How poor…

Unfortunately, I could not find any other free tools for creating App Store images so far. I also read about Photoshop templates and tools which automatically generate screenshots form Simulator. If I ever try these options, I’ll report about may experience in the next posts. For now I decided to try to achieve my goal with appinstitute.com. At least for iPhone images and at least for English and German languages.

 

Cheat-sheets version 1.1

Cheat-sheets app is now multilingual. Support for German and Russian languages has been added in the version 1.1. Not only the user interface was localized, but also the app title. Thus, Cheat-sheets app is now called “Spickzettel” in German and “Шпаргалки” in Russian.

Cheat-sheets version 1.0

I’m glad to announce a new app Cheat-sheets, which is available since last Sunday in iTunes. Cheat-sheets app is for those of us who just cannot keep hundreds of little things in his head. You can organize your cheats in sheets by topic and access them on your iPad, iPhone and Apple Watch.

The first things I wrote down in the Cheat-sheets app was the clothes size of my wife and daughter, guest WLAN password at the office, the names of my colleagues children, id numbers of my smart lamps, wheel type of my vehicle 🙂 It also turned out to be useful to manage little to do tasks in the app. The more you use Cheat-sheets app in the every day life, the more surprising ideas come to one’s head of new use cases.

Of course, there are plenty of other apps for managing notes, todos etc. They are comprehensive and serve their purpose well. However, for really little things, of one or two words it is really helpful to be able to access them easy and quickly.

I thank in advance the users of Cheat-sheets for your feedback in the app store or per email. It is always useful to know whether the development is going in the right direction and depending on that set priorities for new features.

Sharing Data between WatchOS app and iOS app

In most cases the WatchKit App you develop has to exchange data with its iOS App. In earlier versions of watchOS it was enough to define an app group to access the same data from the iOS app and from the WatchKit Extension. But since watchOS 3 things have changed. The apps for watchOS became native, i.e. they are natively executed at the Apple Watch. This implies of course changes in the way how the data is exchanged.

Watch Connectivity Framework is the way Apple provides to synchronize data with WatchOS Apps.

If your existing Watch app and iOS app use a shared group container or iCloud to exchange data, you must change the way you exchange that data in watchOS 2. Because the WatchKit extension now runs on Apple Watch, the extension must exchange data with the iOS app wirelessly. You can do that using an NSURLSession object or using the Watch Connectivity framework, which supports bidirectional communication between your iOS app and WatchKit extension.

To see a corresponding session click here: WWDC 2015 – Session 713 – watchOS

I could also recommend an excellent tutorial/overview for beginners: watchOS 2: How to communicate between devices using Watch Connectivity

Short summary of the most important things about Watch Connectivity Framework:

  • Two separate stores have to be maintained. There is no automatic way for Core Data data to be synchronized with the watch app
  • There are two communication categories: Background transfers and Interactive messaging
  • Background transfers can be: Application context, User Info Transfer and File transfer. Application context is always overridden by the latest data when waiting in the transfer queue. User Info realizes FIFO principle, i.e. all data in the queue will be delivered. File transfer is self explaining.

 

 

iOS Architecture Patterns

Developing sophisticated apps is every time a challenge to find a proper way to provide scalability, testability, enable minimal maintenance cost. Without utilization of design patterns and suitable software architecture development process can get to a nightmare very quickly. Not only for the developer, but also for the customer. Of course, there is no general recommendation for utilization of this or that architecture pattern. It depends on particular requirements and expectations. The most popular architecture patterns are MVC, MVP, MVVM, VIPER etc. These patterns and their realization for iOS are discussed in a great article. Especially, advantages and disadvantages regarding testability and development overhead are discussed their. Comments are also worth reading!

Testphase wird am 30.04.2017 abgeschlossen

Die PolterApp ist nun seit knapp 9 Monaten im App-Store. Sie wurde inzwischen mehrere Hundertmale installiert und wird täglich in verschiedenen Forstbetrieben eingesetzt. Diejenigen Nutzer, die am Beta-Testing aktiv teilgenommen hatten, haben einen großen Beitrag an die Entwicklung der App geleistet. Dank der engen Zusammenarbeit ist ein stabiler Stand erreicht worden, der auch funktional alle Basis-Bedürfnisse der täglichen Arbeit abdeckt. Damit kann die Beta-Phase als erfolgreich bezeichnet werden und wird damit am 30.04.2017 abgeschlossen.

Wie geht es nun weiter? Damit die PolterApp auch weiterhin entwickelt werden kann, wird die App ab dem 01.05.2017 kostenpflichtig zu einem fairen einmaligen Preis von 27,99 Euro angeboten. Das betrifft nur die Neu-Käufe. Alle Beta-Tester, die PolterApp auf ihrem Device haben, müssen nichts tun und nichts zahlen. Wurde die App ein mal kostenlos installiert bleibt sie und die zukünftigen Updates absolut kostenlos. Daher ein Tipp an die PolterApp-Nutzer und potenzielle Interessenten: bis zum 30.04.2017 bleibt noch Zeit die App kostenlos zu erwerben.

HTTPS request with self signed certificate in iOS 10.3

iOS 10.3 seems to handle self signed certificates different then iOS 10.2. Even with the option NSAllowsArbitraryLoads enabled the request fails with the error:

The certificate for this server is invalid. You might be connecting to a server that is pretending to be “Domain name” which could put your confidential information at risk.

To fix the issue install the self signed certificate as usual. Afterwards go to

Settings -> About -> Certificate Trust Settings

and just enable the Full Trust for your root certificate.

No Password Field in Skype Login Dialog

I faced the problem for the first time 2 years ago on Windows 7 computer with Internet Explorer 11. After launching skype a blanc window appeared. There were no input fields for entering user name and password. Searching for the answered in the internet revealed some interesting facts:

  • skype relies on Internet Explorer engine for displaying the login window
  • it plays no role, wether IE is your default browser. You may use Chrome, Firefox, Safari etc., but skype still embeds Internet Explorer and obviously accesses its settings

The login problem was fixed by creating a skype shortcut on the desktop and editing the starting parameters:

"C:\Program Files\Skype\Phone\Skype.exe" /legacylogin

Quotes are important! The starting parameter /legacylogin used to force skype to call the “old fashioned” login window instead of the window based on Internet Explorer. However, in the current version of Skype 7.34 this workaround seems not to work anymore… And again searching and verifying various solutions. At last I found out, that it is possible to start skype directly with username and password parameters!

"C:\Program Files\Skype\Phone\Skype.exe" /username:YourUserName] /password:YourPassword

Hopefully, this workaround continues to work after the next skype update.