Simple UICollectionView pagination with API and Realm database

If you’re using Realm database and a REST API, you may have encountered a pagination issue at some point. That’s what happened in the project I’m working on. Something was wrong with the pagination and I kept adding variables and ifs until I couldn’t remember what was doing what. Then I realized I needed a clean slate, and I created this little project. So, this is a mockup to test a minimum viable pagination and preloading of data from a REST API to feed a UITableView or UICollectionView, using database. Just to make things clear, I am not introducing pagination into … Continue reading Simple UICollectionView pagination with API and Realm database

Swift Tips #1: Extra padding problem on UITextView?

Sometimes when you integrate a design, you need things to be square, everything aligned: buttons, title, images, textView… But wait, what’s that extra padding on the UITextView? You may have tried to print the contentOffset or contentInset without success. That’s not it. However, all your problems can be solved in one line, and here it is:

I wouldn’t call it exactly straight forward, so this is a memo for me and tip for you :)

UIFont not responding or nil

My font does not respond and it says nil when I print it? What’s happening here? Actually, if your UIFont happens to be nil, it’s maybe because you’re not calling it properly! Haha, very funny, I know, but let’s have a look at happened to me recently. Here is what I did: I imported “MyFont-Regular.ttf” and “MyFont-bold.ttf” in Xcode. I set the constants with the font name.

And I set the font to that label in the view:

and … nothing happened, well, the label was displayed but not as wanted. I expected something like label2 and label1 happened. … Continue reading UIFont not responding or nil

SFSafariViewController and OAuth – the Instagram example

I think, as a developer, I’ve never been so excited and frustrated at the same time by the same thing. Sorry for the non-tech reading that, you can stop here, it’s fine ;) My oh-so-frustrating thing is the brand new SFSafariViewController introduced in WWDC 2015, and especially its interaction with OAuth. If you are reading this article, you have probably watched WWDC’s session 504: Introduction to Safari View Controller. And you’ve probably browsed through a lot of articles arguing the pros and cons of SFSafariViewController. Here, I would like to jump straight to the “Web-based authentication” section, when Ricky Mondello … Continue reading SFSafariViewController and OAuth – the Instagram example