iOS Development is easy with XCode, Swift3, UITableView, cocatouch, let's build iPhone, iPad and Macbook Applications.

iOS 11 search bar in tableViewHeader jumps to the top of the screen on focus

There are 2 unanswered posts already on this topic here and here, where no one provided a working solution to this problem. First image shows iOS 10 behaviour of search controller, where you can see hierarchy on the left side and search controller frame on the right framed in red. View at the center in […]

Finding the direction of scrolling in a UIScrollView?

I have a UIScrollView with only horizontal scrolling allowed, and I would like to know which direction (left, right) the user scrolls. What I did was to subclass the UIScrollView and override the touchesMoved method: – (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesMoved:touches withEvent:event]; UITouch *touch = [touches anyObject]; float now = [touch locationInView:self].x; float […]

Swift: Split a String into an array

Say I have a string here: var fullName: String = “First Last” I want to split the string base on white space and assign the values to their respective variables var fullNameArr = // something like: fullName.explode(” “) var firstName: String = fullNameArr[0] var lastName: String? = fullnameArr[1] Also, sometimes users might not have a […]

How to present UIAlertController when not in a view controller?

Scenario: The user taps on a button on a view controller. The view controller is the topmost (obviously) in the navigation stack. The tap invokes a utility class method called on another class. A bad thing happens there and I want to display an alert right there before control returns to the view controller. + […]

The Completest Cocos2d-x Tutorial & Guide List

I’m developing a game using Cocos2d-x to Android and iPhone. At the beggining, I had a lot of problems to start using this library, so, in this question, I want to collect all basic, medium and expert tutorials because there are a lot of info questions doing the same mistakes. When I Started, I had […]

Why is there extra padding at the top of my UITableView with style UITableViewStyleGrouped in iOS7

Starting in iOS7, there is additional space at the top of my UITableView‘s which have a style UITableViewStyleGrouped. Here is an example: The tableview starts at the first arrow, there is 35 pixels of unexplained padding, then the green header is a UIView returned by viewForHeaderInSection (where the section is 0). Can anyone explain where […]

Why doesn't this Regex code work for a P.O. Box string?

I am trying to check if a string is a P.O. Box. I have tested my Regex string with 2 different web browsers and it works just fine. When I use it as shown I cannot get a match. NSString *string = @”P.O. Box 123″; NSString *regexString = @”/\\b[P]\\W*?\\s*?\\.*?\\s*?[o]\\W?\\s*?\\.*?\\s*?(st|stal)?\\W*?\\s*?(box|office) /igm”; NSError *error = nil; NSRegularExpression […]

better way to ensure validity of passed params or variables

I’ve seen many code and one thing that stood out was checking the validity of parameters passed. For e.g. 1) if the string passed in parameter was actually a valid string + (BOOL)isEmptyString:(NSString *) string { if (!string || ![string isKindOfClass:[NSString class]]) return YES; NSString *_string = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; return (!_string.length || [_string isEqualToString:@”null”]); […]

Expand/collapse section in UITableView in iOS

Could somebody tell me the way to perform UITableView expandable/collapsible animations in sections of UITableView as below? or

How to build a framework or library for other developers, the secure way?

We have an idea for an framework or library that will be very helpful for any iOS developer. So we’re seriously thinking about switching from app development to framework/library development. But when we want to charge for the library/framework, we must protect the code somehow. How can we build a framework in such a way […]