iOS (Object C) Tip


  1. How to create (access) AppDelegate object

                 projectNameAppDelegate* sharedApplication = (projectNameAppDelegate *) 
                                                                                                         [[UIApplication sharedApplication] delegate];



                 Using this Object you can access main Window also.
      
         2.   Scheduling to method  


                [NSTimer scheduledTimerWithTimeInterval:1.0f target:self
                                       selector:@selector(didFinishMainURLuserInfo:nil repeats:NO]; 


          3. Re-create frame parameter from existing frame

               
                UIImageView *imageView = [productRowData objectForKey:@"product_image"];
                CGRect rect = imageView.frame;
                rect.size.height = 80;
                rect.size.width = 75;
                imageView.frame = rect;
                imageView.tag = 0;    // tag our images for later use when we place them in serial fashion
                CGRect frame = imageView.frame;
                //frame.origin = CGPointMake(15, 3);
                frame.origin = CGPointMake(00);
                imageView.frame = frame;

          4. When you debug the code, use this code directly to display 'Method Name'

                NSLog(@"%s", __FUNCTION__);

          5. When get value from NSDictionary, use safe method

                    int dlpInt = (([rowData valueForKey:@"DLP"] == [NSNull null]) ? 0 : [[rowData valueForKey:@"DLP"] intValue]);

                    NSString *dateString = (([rowData valueForKey:@"DATE"] == [NSNull null]) ? @"" : [rowData valueForKey:@"DATE"]);


         6. When implementing delegate

            if ([_delegate
                    respondsToSelector:
                    @selector(onScoresSubmitted:)]) {

                [_delegate onScoresSubmitted:success];
            }

        7. Xcode general directory key word
    •  "$(SRCROOT)" - Project directory
    • "$CONFIGURATION_BUILD_DIR" - Project build directory





    No comments:

    Post a Comment

    Add your comment