[iOS – Swift] Create API Wrapper With Alamofire ?>

[iOS – Swift] Create API Wrapper With Alamofire

  In this section I’ll show you how to create an API Wrapper with Alamofire library in Swift. If you want to develop in Objective-C then you should check this post https://hantran.info/ios-create-api-wrapper-with-afnetworking/ Let’s dive into it! 1. Installation Once again, I recommend to use Pod to install external library. Open the Pod file of your project and use this code to install Alamofire:

Then open terminal and:

Installation should be done without any errors. For others way to…

Read More Read More

[iOS] – Different action of AFURLSessionManager for different OS Version ?>

[iOS] – Different action of AFURLSessionManager for different OS Version

AFURLSessionManager  use to download file from internet, it’s provide some useful delegate to make sure developer can tracking process also error etc… Back to the day, my current project was use AFDownloadRequestOperation which made a wrapper of AFHTTPRequestOperation to download file. But from AFNetworking 3.0, they drop the AFHTTPRequestOperation so we cannot use AFDownloadRequestOperation anymore. We decide to use AFURLSessionManager instead of old library. The problem is AFURLSessionManager has different action about the way it’s fire the delegate. Here is a simple block of download function of AFURLSessionManager:

After testing, I see that the…

Read More Read More

[iOS] – Why iTunesConnect show up IDFA when release app? ?>

[iOS] – Why iTunesConnect show up IDFA when release app?

What is IDFA? From Apple: Apple’s advertising identifier (IDFA) is a unique ID for each iOS device and is the only way to offer targeted ads. So basically, any app which contains ads will have IDFA and you must decide which way your app work with those ads. Here is the screenshot when submit app to store and your app contain IDFA:   The problems is even you didn’t show ads inside your app but when try to submit app…

Read More Read More

[XenForo] – How to create an input box with autocomplete for username. ?>

[XenForo] – How to create an input box with autocomplete for username.

I starting use XenForo (XF) for several years to build some website. Basically XF base on Zend framework but not stop from that, XF also bring so many great feature for developers. I’ll write all of those features later, but now I want to show you one of the really great thing in XF template. I’m creating a from which allow admin to input the user name and it must show some suggestion (auto complete). The purpose is it will…

Read More Read More

[iOS] – Create API wrapper with AFNetworking ?>

[iOS] – Create API wrapper with AFNetworking

Okay, so why AFNetworking? Well, this is a small quote from github: Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac. That’s enough for a library right? Let’s start! 1. Installation There are some way to install the library, I choose the Pods method because it’s simple and easy to upgrade after….

Read More Read More

[iOS] – Prevent wrong loading image inside of TableViewCell when scrolling. ?>

[iOS] – Prevent wrong loading image inside of TableViewCell when scrolling.

My current project require a screen which contain a list view on it. Each item of that list will show the information of a drug store and there is a image on it too. It’s really simple. In iOS we just need to drag a UITableView to the controller, add a UITableViewCell to it, create a Cell class for that cell and finally inside the cellForRowAtIndexPath we just fill data for that cell.  Okay, everything work well but… until you scroll the list…

Read More Read More

[PHP] – json_decode() for big integers ?>

[PHP] – json_decode() for big integers

json_decode() is use for decode a json text to object (or array) in PHP. For normal case, below code will decode a json string to an array in PHP:

But if the json contain a really big integers then the problem will be appear, take a look at below code:

The result will be:

So the solution here is we need to tell the json_decode function that we need to convert the big integers to string. Something like…

Read More Read More

[Android] – How to solve Fragment in ViewPager not restored after popBackStack ?>

[Android] – How to solve Fragment in ViewPager not restored after popBackStack

Problem   A Fragment is not reattached to its hosting ViewPager after returning from another fragment. Situation One Activity hosting a Fragment whoselayout holds a ViewPager. The ViewPager is populated by a FragmentStateViewPagerAdapter. The single Fragments hosted inside the pager (PageFragment for example) can open sub page lists, containing a new set of pages.