Skip to main content

Posts

Showing posts from September, 2014

Everything about BLE with iOS Part2 (Implementation)

Today we will learn how can we implement a BLE receiver and a BLE transmitter with iOS SDK. For this we will use both the SDK describe in part1 . CoreLocation :  We will use for implementing the central which accept the data from the peripheral. CoreBluetooth : We will use for implementing the peripheral (has data to send). Central: It is device who can receive data from the peripheral if it knows peripheral proximity UUID of the peripheral. So if you have an iBeacon then seller must provide you proximity UUID for the beacon.  For listening to iBeacon you must initialize a beacon region with the proximity UUID. API for initialize the region is in core location framework: - ( instancetype )initWithProximityUUID:( NSUUID *)proximityUUID identifier:( NSString *)identifier There are multiple variant of this method for specifying major and minor value with the UUID. You can select based on your requirement. Here for the example purpose we are not grouping the iBeacon so we

Everything about BLE with iOS Part1 (Introduction)

In this article we will learn how to turn your iPhone to behave as peripheral (who has data to send) or central (who receive the data). What is BLE (Bluetooth Low energy device) ? Bluetooth LE is a wireless personal area network technology like its previous incarnation, Classic Bluetooth. It can be use to transfer and receiving of the data. What is difference between Classic and LE ? BLE has low power consumption and low data transfer rate. BLE can support large number of slaves. On the other hand Classic (3.0) support maximum 7 devices connectivity. Unique feature of BLE is advertising  functionality,  So other devices can scan,  connect and  receive data from the advertising BLE device. Other difference is in classic you need to pair the devices first for the communication. Terms: Peripheral:  It is device which advertise the service. In client-server architecture form we can say peripheral is server which has data to send to client. The basic difference i

NSThread with Asynchronous Request

NSThread: It is class used in Cocoa framework to create a thread.You have to specify a target and selector to create a new thread in objective c. So the selector or method is main entry point of your thread.  Detail: What happen once the thread execute all the code in the method (Thread main routine)? Thread is terminated after execute all the code in the entry(its main routine) routine. So how we can run an asynchronous request on NSThread ? What is Async request? It is non blocking request which permit the application to do other task side by side as request is in continue. So it enhance parallelism in the application. Now question is how we can prepare a asynchronous request in iOS: - ( void ) startAsyncRequestWithUrl:( NSString *)urlString{     assert (urlString != nil && urlString. length > 0 );     NSURL * url = [[ NSURL alloc ] initWithString :urlString];     NSURLRequest * urlRequest = [[ NSURLRequest alloc ] initWithURL :url cac

Design Pattern in iOS

Target/Action: Design pattern known for handling to controls (UIButton, UITextField etc) events. Target Action In the above diagram UIViewController (target) is responsible for action of UIButton (control). This design pattern enables to write the custom logic of controls in any object (UIViewController) without sub classing the control (UIButton) object. So if you connect a button to an outlet in storyboard it depicts the target/action paradigm. The action is defined by the name of a selector. The target can either be a concrete object or it can be NULL We can take the example of this pattern as if we press (Action) a electricity switch then target (Fan) will start rotating. Code : In programming we are using this pattern when we use the following method for any controls: addTarget:action:forControlEvents: When we add any action through xib or storyboard then also we are using action target design pattern. So any