There is a memory leak issue in Timer if we use selector parameter. If you use above code, the self will be a strong reference to target until the timer is invalidated, and we usually put timer as a private var in the class, so it’s a critical trap if we forget to stop timer […]
For any debug code, please wrap it into #if DEBUG … #end block.
Reason: Sometimes we need to add a temp test code but forget to disable it in the release ( production ) version.Wrap it to DEBUG scope will keep the release code clean & safe. Example: So, anyway please make sure your test code is for DEBUG mode only.
NSLocalizedString with variables formatter
Here is an issue of NSLocalizedString, this line: NSLocalizedString(“Page (currentPage ?? 1)/(totalPages ?? 1)”, comment: “”) The string ‘Page’ should be localized but currentPage and totalPages are number variables, they are unable to pre-translated into localized string table.So the correct way is: NSLocalizedString(“Page”, comment: “”) + ” (currentPage ?? 1)/(totalPages ?? 1)”orString.formatted( NSLocalizedString(“Page %d/%d”, comment: […]
UIAlertController replacement
Here is a known UIAlertController crash on iPad: Please use UIPadAlertController to create UIAlertController, provide sourceView and sourceRect on iPad version as per UI design document. The UIPadAlertController fixed crash issue even not provide sourceView on iPad, it will use .alert style if you have not provide sourceView. Code example:
performBatchUpdates replacement
For the generate a better crash log, we have replacement on UITableView:performBatchUpdates and UICollectionView::performBatchUpdates. Please use TracedUITableView::tracedPerformBatchUpdates and TracedUICollectionView::tracedPerformBatchUpdates. For example, the following code is before change: Now please change it to:
iOS Developer Manual – 1.0
Get Started When you start creating UI like this, you will consider two major things, what is for display and how to display them. For what is for display, we called it State, in this UI, the State are 3 items. Each item have: title date created and time For how to display, it’s a […]
How to write unit test on async module
Hello, If a module has async code and we want to perform unit test on it, the normal way will cause the async code to have no chance to execute. Because the testing module is async so we have to waiting the async code complete and then do test assert. We can use XCTestExpectation for […]
iOS UI Component Testing
We usually test UI by hand in iOS development. It’s a very inefficient way. In this doc we suggest you write the UI component test in iOS development. Test by hand: Use it only in the integration phase. Need play app as a normal user. Low productivity on testing only one UI component. UI component […]