Translate

Tuesday, May 28, 2013

CustomCell

View Didload


objArray = [[NSMutableArray alloc] initWithObjects:
                [[ListObjects alloc] initWithName:@"Steak" andDesc:@"Rare"],
                [[ListObjects alloc] initWithName:@"Steak" andDesc:@"Medium"],
                [[ListObjects alloc] initWithName:@"Salad" andDesc:@"Caesar"],
                [[ListObjects alloc] initWithName:@"Salad" andDesc:@"Bean"],
                [[ListObjects alloc] initWithName:@"Fruit" andDesc:@"Apple"],
                [[ListObjects alloc] initWithName:@"Potato" andDesc:@"Baked"],
                [[ListObjects alloc] initWithName:@"Potato" andDesc:@"Mashed"],
                [[ListObjects alloc] initWithName:@"Bread" andDesc:@"White"],
                [[ListObjects alloc] initWithName:@"Bread" andDesc:@"Brown"],
                [[ListObjects alloc] initWithName:@"Hot Dog" andDesc:@"Beef"],
                [[ListObjects alloc] initWithName:@"Hot Dog" andDesc:@"Chicken"],
                [[ListObjects alloc] initWithName:@"Hot Dog" andDesc:@"Veggie"],
                [[ListObjects alloc] initWithName:@"Pizza" andDesc:@"Pepperonni"],
                nil ];

cellForRowAtIndexPath

    static NSString *CellIdentifier = @"Cell";
    ThumbCellView *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    cell = [[ThumbCellView alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil imageName:objArray width:self.view.bounds.size.width];
    cell.backgroundColor=[UIColor clearColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;


ListObjects Class

-(id) initWithName:(NSString*)cateName andDesc:(NSString*)tltName
{
    self = [super init];
    if(self)
    {
        self.catName = cateName;
        self.titleName = tltName;
    }
    return self;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier imageName:(NSArray *)imageList width:(int)width
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
          int val;
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            if (width==320)
                val=0;
            else
                val=25;
        }
        else
        {
            if (width==768)
                val=0;
            else
                val=25;
        }
        
        for (int i=0;i<[imageList count];i++)
        {
            UIButton* cellBgImg;
            
            if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
            {
                cellBgImg = [[UIButton alloc] initWithFrame:CGRectMake(50+i*140+val, 10, 70, 90)];
            }
            else
            {
                cellBgImg = [[UIButton alloc] initWithFrame:CGRectMake(70+i*180+val, 65, 103, 133)];
            }
            
            UIImage *img=[UIImage imageNamed:@"image.png"];
            [cellBgImg setBackgroundImage:img forState:UIControlStateNormal];
        
[cellBgImg setTitle:[NSString stringWithFormat:@"%d",i+1] forState:UIControlStateNormal];
            cellBgImg.titleLabel.font=[UIFont fontWithName:@"Arial" size:0.0];
            
            cellBgImg.tag=i;
            
[cellBgImg addTarget:self action:@selector(btnpress:) forControlEvents:UIControlEventTouchUpInside];
cellBgImg.backgroundColor=[UIColor clearColor];
            [self addSubview:cellBgImg];
            
        }
    }
    return self;
}

Sunday, May 26, 2013

Apple Push Notification


#pragma mark -
#pragma mark Application lifecycle

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
    NSLog(@"Registering for push notifications...");    
    [[UIApplication sharedApplication
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound)];
}


- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken1 { 
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
NSString *str = [NSString stringWithFormat:@"%@",deviceToken1];
NSLog(@"%@",str);
NSString *stringWithoutOpenB = [str stringByReplacingOccurrencesOfString:@"<" withString:@""];
NSString *stringWithoutCloseB = [stringWithoutOpenB stringByReplacingOccurrencesOfString:@">" withString:@""];
NSString *trimmedString = [stringWithoutCloseB stringByReplacingOccurrencesOfString:@" " withString:@""];
if (standardUserDefaults) {
[standardUserDefaults setObject:trimmedString forKey:@"DT"];
[standardUserDefaults synchronize];
}
    NSLog(@"%@",str);
}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err { 
    NSString *str = [NSString stringWithFormat: @"Error: %@", err];
    NSLog(@"%@",str);  
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    for (id key in userInfo) {
        NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
    }    
}

Monday, April 22, 2013

Objective C/iPhone/iPad/iOS Interview Questions


1. What is delegate? 

2. What is protocol? Types off protocols? By default Which type ?
3. What is the difference between Delegate and Protocol? 
4. What are categories?
5 . Difference b/w categories and Extend?
6. Difference b/w categories and Inheritance?
7. Is there over loading function in object c?
8.How objective C supports overloading and overriding ?
 9. How OOPS Concept supports to ObjectiveC?
 10.What is MVC? How It’s supported to objectiveC?
 11.Explain the Application LifeCycle?
 12.What is Protocol? Types of Protocols?
 13. Is Synthesis required? What is the Importance of it?
 14 How  should you manage memory?
 15. Delegate Methods?
 16.What are the controls?
 17.what is xib?
 18.Waht is the difference b/w loadview and viewdid load?
 19. How to change one controller to other controller?
 20. How to change the Default controller?
 21. How to Provide Multiple options to the user?
 22.What are required delegates for Table View?
 23. Table View Delegate Methods?
 24. How the memory allocated for table view?
 25.what are UI Text field methods?
 26. Difference b/w simulator and Device?
 27. Differences b/w IPAD And Iphone?
 28. Features of 4.0version?
 29. Difference B/w versions?
 30. How you Customize the table view?
 31. Difference B/w C,C++,ObjectiveC?
 32. What is Garbage Collection How it’s supported?
 33. Difference b/w Copy and Retain?
 34. Differences b/w Copy and Mutable Copy?
 35. Difference b/w Release  and Auto Release?
 36. What is the base class for all the classes?
 37. What are Data Types? What is the Default Data type?
 38. What are Access Specifiers? What is the Default Access Specifier?
 39. Differences b/w  String and NSString?
 40. Array allocation is Contiguous ?
 41. Differences b/w NSArray and NSMutable Array?
 42. What are the Design Patterns?
  Design Patterns :
  1. MVC
  2. Singleton :
A system only needs to create one instance of a class, and that instance will be accessed throughout the program. Examples would include objects needed for logging, communication, database access, etc. You could pass such an instance from method to method, or assign it to each object in the system. However, this adds a lot of unnecessary complexity.

  1. Factory design pattern :
The factory method pattern is an object-oriented design pattern to implement the concept of factories. Factory method Pattern is to "Define an interface for creating an object, but let the subclasses decide which class to instantiate.

43. What is singleton object? How it’s supported?

44.   Instance method followed by………………………
                Member variable
45.  Instance method begins with?
      -
46. Class method begins with?
     +
47. @interface
                Methods define
48. @implementation
                Define methods are implemented
49. Default constructor syntax is?
                - (id) init.

50. What is the difference b/w dismissmodelview control and presentviewmodel controller?

51.  Which API’s are using in u r application?
      API means frameworks like UIkit, foundation, Core animation

52. What is the cocoa?
     Object c framework called COCOA. The specific part of the framework used for iPhone app development is called Cocoa Touch

53 .What is the difference Between APPKit and UIKit?
   there is NO APPKit in iphone and there is no UIKit in Mac OS

54. What is diff between Get and Post methods?
55. What is NSPredicate?
56. which class is used for sorting the objects in array?
57. How to customize u r app in iphone?
Winterboard is an application that let you customize your iPhone / iPod 2.0+.
58. What is the Winterboard?
Winterboard allows you to customize Springboard of your iphone. Using Winterboard you can change iPhone icons, customize applications, status bar graphics, iPhone dock graphics, install themes and change wallpapers of your iPhone Springboard. You can even customize sounds on your iPhone. With Winterboard you can theme almost everything that comes to your mind. Before iPhone 2.0 there was Summerboard but Winterboard has replaced it since iPhone 2.0 and can even load themes of Summerboard.
59. What is the springboard?
Springboard is the standard application that manages the iOS (formerly iPhone OS) home screen.
60. Is it support multiple inheritance? How it’s over come?
Not supported                                                                                                     
61. What is the memory management?
                It allocates and reallocates memory and find out memory leaks.
62. What is the ton?
                Singletons are a class that only gets instantiated once in your application’s run-time.
63. How many layers are there in iphone sdk?
                .cocoa touch layer
                                Address book UI
                                UIkit
                .media layer
                                .audio toolbox
                                .audio unit
                                .AV foundation
                                .core Audio
                                .core graphics
                                .media player
                                .open GL ES
                                .quartz Core
                .core service layer
                                .address book
                                .core foundation  
                                .core location       
                                .foundation          
                                .system Configuration
                .core os layer
                                .CF network          
                                .security
                                .system
64. What is Parsing? Types of Parsing? Differences b/w types?
65. How File Handling should be done?
66. Permanent Storage?
67. What is APP Delegate? Why It’s used?
68. How handling the Data Base? Which Database your used?
69. Differences b/w SQLite and CoreData?
70. How Mapkit is used?
71. How change the Application Name?
72. What are the Frameworks you are used?
73. Essences of Library File?
74. What is Web Service? How it’s connected?
75. What it is NSURL?
76. Difference b/w SAX Parsing and DOM Parsing?
77. How to Implement Check Boxes and List View and Tree View and Combo box?
78.  What is Notifications? Types of Notifications?
79.  What is Push Notification?
80. How to handle device orientation?
         ShouldAutoRotatetointerfaceorientation – method
81. Deployment steps?
Deplolyment :
1)       Open applicatons- uitilites-keychain access –certificate assistance – requested a certificate from  a certifate authority
Email :
Savetodisk(radio button)
Ok
Certificate icon Is created in desktop. (developer certificate is created)
2)       Upload the developer certificate into developer.apple.com
Registed login :
3)       Create the provisioning profile from developer.applie.com and download it to system.

4)       Open the XCode and select the window -> organizer -> select the device and under provisioning profile tab drag it to device.

82. Steps for App Store Submission? 
83. What is IPA?
84. Adhoc distributions?
85. what is plist?
86. what is Multithreading? How it’s supported?
87.what is the dimensions of IPHone And IPAd?
88.What is the dismismodal view controller and present modal view controller?
89. Difference b/w Non Automic and Automic ?
90. Difference b/w Nib and Xib?
91. Difference b/w Data Source and Delegate?
92.what is Selector?
93.Difference b/w Array and NSDictionary?
94.Difference b/w Super and Base?
95. What are Application Life Cycle Phases?
96.How to build  the Application?
97.How to handle Errors and Bugs and Exceptions?
98. How to test the Application?
99. How to create the Custom controls?
100. How to Change the Color  for title bar of navigation bar?
101. Difference b/w Navigation And  Tab Bar controller?
102. What is JSON?
103. What is Gestures?
104. Difference b/w #define and #paragama and  #import?

Tuesday, April 9, 2013

iCloud implementation iOS5

STEP BY STEP METHOD TO IMPLEMENT ICLOUD 
Make sure your device is running iOS 5.

Turn on iCloud.
When you turn on a new iOS device or after you’ve completed the update to iOS 5, follow the onscreen instructions to activate your device and set up iCloud.
If you skipped the setup process or want to change your iCloud settings, tap the Settings icon on the Home screen and select iCloud.
Customize your settings.
Tap the Settings icon and select iCloud. Tap the On/Off switches to enable individual iCloud services, including Photo Stream, Documents, Find My iPhone, and more.
To enable Backup, tap Storage & Backup, then switch on iCloud Backup.
Now go to the Provisioning Portal to enable iCloud storage for your iOSapplication. Enabling this feature requires that you have an updated provisioning profile on your development systems.Xcode 4 handles this step for you automatically.
Add a new Entitlements file to your application and use it to configure the iCloud features for your application uses. Set the keys and values like this:
 
 
 
           •Now we have to do Entitlements  settings. Go to your target and select Summary tab and do the settings so           that it will look like this:
 
 
 
           •Now we have to do some setup for bundle settings. For this add a new setting bundle file under
           •Resource option in your project , it will have extension .bundle. Now this file contain a Root.plist file.
           •In Root.plist you will get 2 key, one is Preference Items with 4 items and another is Strings Filename. Delete all the items under Preference Items and setup it like this:
 
 
Now come on code, Go to your appDelegate.m file and write these line indidFinishLaunchingWithOptions method :
 
   [[NSUserDefaults standardUserDefaults] setValue:@"YES"   forKey:@"enableiCloud"];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSURL *iCloudURL = [fileManager                  URLForUbiquityContainerIdentifier:@"LCRABX9EHK.com.sapnasolutions.iCloudTest"];
    BOOL check = [fileManager isUbiquitousItemAtURL:iCloudURL];
    NSUbiquitousKeyValueStore *cloudStore = [NSUbiquitousKeyValueStore   defaultStore];
    [cloudStore setString:[iCloudURL absoluteString] forKey:@"iCloudURL"];
    [cloudStore synchronize]; // Important as it stores the values you set before on iCloud

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"saved.png"];
    BOOL existFile = [fileManager fileExistsAtPath:writableDBPath];
    // If the file exist then send it on iCloud.
    if (existFile) {
        NSError *errorOut=nil;
        BOOL success =[fileManager setUbiquitous:YES itemAtURL:[NSURL   URLWithString:writableDBPath]  destinationURL:iCloudURL error: &errorOut];
        NSLog(@"Error: %@", errorOut);
    }

query = [[NSMetadataQuery alloc] init];
        
        [query setSearchScopes:[NSArray   arrayWithObjects:NSMetadataQueryUbiquitousDataScopeNSMetadataQueryUbiquitousDocumentsScope, nil]];
        
        [query setPredicate:[NSPredicate predicateWithFormat:@"kMDItemFSName LIKE '*.png'"]];
        
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryHandler:)name:NSMetadataQueryDidFinishGatheringNotification object:query];
        
        [query startQuery];
 
- (void)queryHandler: (NSNotification *) inNotification{
    NSLog(@"The number of results: %i", (int)[query resultCount]);
}