Category: Objective-C

Coming soon in 2020: objc_direct

Before you start reading this tutorial, please read about method swizzling. The Objective-C model of object-oriented programming is based on message passing to object instances. In Objective-C one does not call a method; one sends a message.  In Objective-C, the target of a message is resolved at runtime, with the receiving object itself interpreting the message. A method is identified

Continue Reading →

Interacting with Javascript in WKWebView

You can use the WKWebView class to embed web content in your app. To do so, create a WKWebView object, set it as the view, and send it a request to load web content. After creating a new WKWebView object using the initWithFrame:configuration: method, you need to load the web content. Use the loadHTMLString:baseURL: method to begin loading local HTML files or the loadRequest: method to begin

Continue Reading →

How to setup your project in Xcode to support multiple frameworks and sub-projects using XCCONFIGS?

If you have multiple targets use config files. This is the way to create them. Below is a sample of what you can specify in the config files. ARCHS = arm64 CLANG_CXX_LANGUAGE_STANDARD = gnu++98 CLANG_CXX_LIBRARY = libstdc++ LD_NO_PIE = NO OTHER_LDFLAGS = -Wl,-warn_compact_unwind HEADER_SEARCH_PATHS = ../code/ FRAMEWORK_SEARCH_PATHS = ../debug One of the things you can

Continue Reading →

Adding a navigation controller in Tab bar controller

[sourcecode language=”objc”] – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. UIViewController *viewController1 = [[TPFirstViewController alloc] init]; UIViewController *viewController2 = [[TPSecondViewController alloc] init]; self.tabBarController = [[UITabBarController alloc] init]; UINavigationController *controller1 = [[UINavigationController alloc] initWithRootViewController:viewController1]; self.tabBarController.viewControllers = @[controller1, viewController2]; self.window.rootViewController = self.tabBarController; [self.window makeKeyAndVisible];

Continue Reading →

Developing for both iPhone and iPad, helpful tips

Use these #defines to make your life easy : [sourcecode language=”objc”] #define IS_IPAD ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) #define IS_IPAD_LOW_RES ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && [[UIScreen mainScreen] scale] == 1.0) #define IS_IPHONE ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) [/sourcecode]

Continue Reading →

Lets do some twists in iOS

Ever wondered how you can turn a view along the x-axis or y-axis. You can do that using the CATransform3DMakeRotation in iOS. Its pretty cool. You can use animation to even make it more awesome. In the CATransform3DMakeRotation method you can change the x,y,z values to 1 for rotating the views along the respective axis. Some uses

Continue Reading →

Taking screenshots in iOS

There are two ways to do this. option 1 ) [sourcecode language=”objc”] CGSize size = [self.view bounds].size; UIGraphicsBeginImageContext(size); [[self.view layer] renderInContext:UIGraphicsGetCurrentContext()]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [/sourcecode] The above code is helpful when you have static uiviews. Consider you have a many uiviews and you are moving them around with gestures. At this instant, if

Continue Reading →

Strong and Weak in iOS

I had to refer to this in my blog, because its one of those examples out there which makes it really easy to understand the difference between strong and weak pointers.First of, I will copy the apple definitions and then paste the example, see the difference. __strong is the default. An object remains “alive” as long

Continue Reading →

Static build not building for facebook ios app

=== BUILDING NATIVE TARGET facebook-ios-sdk OF PROJECT facebook-ios-sdk WITH CONFIGURATION Release === Checking Dependencies… error: There is no SDK with specified name or path ‘Unknown Path’ ** BUILD FAILED ** iOS Simulator build failed If you are getting this error, you need to go to the script: ./build_facebook_ios_sdk_static_lib.sh alter the path as shown below: [sourcecode

Continue Reading →