Showing posts with label iphonesdk. Show all posts
Showing posts with label iphonesdk. Show all posts

Friday, 30 November 2012

Beginner's Choice

My dear developers,

Am Vishwanath, started my career directly from learning Objective-C building iOS applications. Before this i was just aware of C and C++ languages only. Now i have over 2.8 years on Obj-C and 2.4 years on iOS SDK. Have built apps on iPhone, iPod and iPad applications.
So far in my journey i have learned some skills like-

  • Hands on features/services like MapKit, Location based services, Web services based, XML, JSON, PDF, Paypal, in-app Purchases, Core data, iCloud.
  • Hands on e-commerce applications, Social networking applications, Event based applications.
In my journey i have built lots of sample applications to learn different concepts, different frameworks. Just for learning my self. Have come across lots of hurdles- found solutions, tricks and tips to complete the tasks in a easier way.Using these experiences which i gained so far we can build simple applications just like that in no time, and can decide which will be best out of many ways to accomplish the tasks/hurdles building any applications.
  
Now i can say that am a Beginner's Level-2 in iOS development. So want to help my co-developers, who want to start a career in iOS development or Beginner's Level-1. So that you can cross these hurdles in no time and develop great applications in less time.

To start this i will be posting Tutorials, Tips, Tricks, to complete Tasks and many more in this blog. So subscribe to this blog & be in touch to save your time in development. These tips will be really helpful in real time while building apps in many ways, so just have look on it.

Tutorials

Tips

Tricks
This list will be growing on, so keep looking at it every day.

Apart from this if you have some of good blogs or tutorials posted by you, send me a mail/ add in comments with link & description i will share it over here so that it will be useful to many other developers.

If you come across some issues & want any help/guidance from me just add a comment will have a tutorial for that, showing at which time you faced the issue with a solution to that, even with the details of the developer who actually got this issue (if they want so).

You can also suggest or request on what next topics should be?

So keep looking, keep coding, keep developing.

Thanks

How to add custom fonts to your iOS app

To have well designed UI in any app, we need to have some thing different then any other apps. This may be in terms of images, colors, contents, fonts, text styles, way of presentation. And suppose if the Xcode doesn't have the required things which we required.

Here is a tip for how to add your own custom font to use in any iOS app just in 3 steps.

1) Add the font file to your resource bundle, the file extension will be “otf”. Here is a font file of STIXGeneral.

2) Add the font info in your application info.plist file, once added your info.plist file will look similar like below.









3) Then nothing, just use the font any where in your app as required. The one is shown below, similarly


[_myLabel setFont:[UIFont fontWithName:@”STIXGeneral” size:44]];


That's it now your UI shows your own custom font.

Thanks
Happy Coding.

Saturday, 20 October 2012

How to make use of Digital Color Meter application in MAC


We have an application in our MAC called "DigitalColor Meter". We can use this application into our application to get the color code for RGB.
Steps:
1)   Open Digital Color Meter application in MAC, can use spot light for easy search.
2)   Keep the required mode to "RGB as Percentage"
3)   Using the mouse pointer go to the required color on the screen.
4)   Note down the RGB values in percentage.
5)   In our code you can use the method 
[UIColor colorWithRed:0.663 green:0.855 blue:0.341 alpha:1]

Convert percentage values into fractions. like 53.5% will become 0.535. Use the respective RGB values in the code, and alpha value must be 1.
Run the application, you will get the exact color required.
For HTML users
In the "DigitalColor Meter" application set the mode to "RGB As actual value, 8-bit", so that you can get the RGB value as decimal number from 0-255. Note this RGB numbers.
  
Use RGB-HEX to get the hexadecimal number of the required color by inserting these RGB values.
for example:
R - 85   G - 20   B - 30
required color in hexadecimal is : #55141E
You can use this hexadecimal value, to get the required color in html code.

Happy Coding.

Friday, 19 October 2012

delegates in Objective C

What is a Delegate?
Technically speaking, a delegate is just an object that has been assigned by another object as the object responsible for handling events.

An example with real time situation:
A xyz office has some 5 counters, you will enter into office go to counter 1 and submit the some details etc. And the counter 1 will tell you to wait for some time and move to counter 3 to finish to get your work complete. In this case counter 3 is your delegate which handles your events, which is referred by counter 1. Here the same counter 1 may also be the delegate, to handle your events.

Why Delegate is required?
In one word we can define delegate as “Call-back”. Means after performing some task, who, why and how will handle the events.

What is the use of this Delegate?
While building any applications or projects delegates play a very important roles. In some situations some tasks should be performed out of the area and after finishing we should get to know the results, whether task is achieved or in progress or stopped. These statuses can be accessed by using the delegates.

Predefined Example:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@“Hello” message:@“This is an alert view” delegate:self cancelButtonTitle:@“OK” otherButtonTitles:nil];

The initializer of the UIAlertView class includes a parameter called the delegate. Setting this parameter to self means that the current object is responsible for handling all the events fired by this instance of the UIAlertView class. If you don’t need to handle events fired by this instance, you can simply set it to nil:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@“Hello”message:@“This is an alert view” delegate:nil cancelButtonTitle:@“OK” otherButtonTitles:nil];

If you have multiple buttons on the alert view and want to know which button was tapped, you need to handle the methods defined in the UIAlertViewDelegate protocol. You can either implement it in the same class in which the UIAlertView class was instantiated or create a new class to implement the method, like this:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog([NSString stringWithFormat:@“%d”, buttonIndex]);
}

To ensure that the alert view knows where to look for the method, create an instance of SomeClass and then set it as the delegate:

SomeClass *myDelegate = [[SomeClass alloc] init];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@“Hello” message:@“This is an alert view” delegate:myDelegate cancelButtonTitle:@“OK” otherButtonTitles:@“Option 1”, @“Option 2”, nil];
[alert show];


How to create our own delegates?
To create your own delegate, first you need to create a protocol and declare the necessary methods, without implementing. And then implement this protocol into your header class where you want to implement the delegate or delegate methods.

A protocol must be declared as below:

@protocol ServiceResponceDelegate <NSObject>

- (void) serviceDidFailWithRequestType:(NSString*)error;
- (void) serviceDidFinishedSucessfully:(NSString*)success;

@end

This is the service class where some task should be done. It shows how to define delegate and how to set the delegate. In the implementation class after the task is completed the delegate's the methods are called.

@interface ServiceClass : NSObject
{
id <ServiceResponceDelegate> _delegate;
}

- (void) setDelegate:(id)delegate;
- (void) someTask;

@end


@implementation ServiceClass

- (void) setDelegate:(id)delegate
{
_delegate = delegate;
}

- (void) someTask
{
...
...
...
perform task
...
...
...
if (!success)
{
[_delegate serviceDidFailWithRequestType:@”task failed”];
}
else
{
[_delegate serviceDidFinishedSucessfully:@”task success”];
}
}
@end

This is the main view class from where the service class is called by setting the delegate to itself. And also the protocol is implemented in the header class.

@interface viewController: UIViewController <ServiceResponceDelegate>
{
ServiceClass* _service;
}

- (void) go;

@end



@implementation viewController

//
//some methods
//

- (void) go
{
_service = [[ServiceClass alloc] init];
[_service setDelegate:self];
[_service someTask];
}


That's it, and by implementing delegate methods in this class, control will come back once the operation/task is done.
If you liked this tutorial or found something wrong with it please let me know!
I would love to hear your experience with it.