Thursday, August 24, 2017

How to get iPone document directory from enterprise distributed application (iOS 10.0 +)

Due to Apple has tightened the security with their enterprise distribution with iOS 10.0 and above, we can't get the device container logs from our usual approach. 

Here what I am suggesting, change the singing of your real enterprise application from Enterprise Distributor to Enterprise Development. So we can pull the container using our old approach. After you are doing this exercise your original app will override and it may useless.

  1. Create a sample test project using same bundle id, increasing version
  2. Use same device which your Enterprise Distributor build already installed. (This is your real app which has the issues. The app we need to get the container)
  3. Use the sample app (step 1.) and run through with Developer singing(both distributor cert and developer cert should be from same apple enterprise developer program).

Happy Debugging.

Monday, March 10, 2014

Block Type


Return_Type  (^ Block_Name) (Parameters)



void (^ x) (void)  =   ^{
       NSLog(@"block--without--parameter--without--returntype");
};
    
    
void (^ xx) (int)  =  ^(int a){
        NSLog(@"bloc--with-one-parameter--without--returnType -- %d", a);
};

    
void (^ xxx) (intNSString *)  =  ^(int a, NSString *s){
        NSLog(@"block--with-two-parameters--without--returnType - %d -- %@", a, s);
};

    
NSString* (^ xxxx) (intNSString *)  =   ^(int a, NSString *s){
        NSString *ss = [NSString stringWithFormat:@"block--with--parameters--and--returntype %@ - %d", s, a];
        return ss; 
};

Monday, September 2, 2013

how to expire tweets after time.

Now tweeter can expire tweets after some time. its easily can append # tag like below to your tweets.

#timeX(m-minutes, h-hours, d-days) #2m

eg: #2m, #2h, #2d.

Monday, October 15, 2012

Remove UIWebView's key bord top bar.


UIWindow *keyboardWindow = nil;
- (void)removeBar { 
    // Locate UIWebFormView.
    for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
        if (![[testWindow class] isEqual:[UIWindow class]]) {
            keyboardWindow = testWindow;
            // Locate UIWebFormView.
            for (UIView *possibleFormView in [keyboardWindow subviews]) {       
                // iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
                if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
                    for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
                        NSRange range = [[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"];
                        if (range.location != NSNotFound) {
                            [subviewWhichIsPossibleFormView removeFromSuperview]; 
                        }
                    }
                }
            } 
        }
    }   
}

Sunday, October 7, 2012

UIWebView insert Items



  • Insert Image
<img src="imagePath/imageName.png" width ="280px" height = "187px"/><br />

  • Insert Link
with Title
<a href='http://www.link.com/' style='color:#fd9600;'>LinkTitle</a>
with Image
<a href='http:///www.link.com'><img src='imagePath/image.jpg' width ='280px' height = '179px'/></a>


Thursday, June 14, 2012

Add Views to UIAlertView


1. Create UIAlertView with buttons using UIAlertView initWithTitle methods with buttons.
2. create the views wich you wish and add it to AlertView using addSubView: methods.
3. use below delegate method to organize your views.
     - (void)willPresentAlertView:(UIAlertView *)alertView

// create alertView
-(void)configureAlert{
     alertView = [[UIAlertView alloc] initWithTitle:@"Tittle" message:@"message" delegate:self                                    
cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok",nil];
     textField = [[UITextField alloc] initWithFrame:CGRectMake(12, 86, 262, 28)];
     [textField becomeFirstResponder];
     [textField setPlaceholder:@"Password"];
     [textField setReturnKeyType:UIReturnKeyDone];  
     [textField setInputAccessoryView:customAccView1];
     [textField setFont:[UIFont fontWithName:@"Helvetica Neue" size:18]];
     [textField setContentMode:UIViewContentModeBottom];
     [textField setBackgroundColor:[UIColor whiteColor]];
     // vertical alignment of text in textField
     [textField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
     [alertView textField];
     [alertView show];
}

- (void)willPresentAlertView:(UIAlertView *)alertView { 
          [alertView setFrame:CGRectMake(17, 30, 286, 188)];
          NSArray *subviewArray = [alertView subviews];
          UILabel *label = (UILabel *)[subviewArray objectAtIndex:2];
          [label setFrame:CGRectMake(10, 46, 260, 20)];
          UIButton *buttonOk = (UIButton *)[subviewArray objectAtIndex:4];
          [buttonOk setFrame:CGRectMake(10, 130, 128, 42)];
           UIButton *buttonCancel = (UIButton *)[subviewArray objectAtIndex:3];
          [buttonCancel setFrame:CGRectMake(148, 130, 128, 42)]; 
}

   
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
     // button actions
}

Wednesday, June 13, 2012

Transparent UIWebView

To transparent the UIWebView and remove the scrolls.

webView.opaque = NO;
webView.backgroundColor = [UIColor clearColor];
for(UIView *view in webView.subviews){ 
     if ([view isKindOfClass:[UIImageView class]]) {
          // to transparent 
          [view removeFromSuperview];
     }
     if ([view isKindOfClass:[UIScrollView class]]) {
          UIScrollView *sView = (UIScrollView *)view;
          //to hide verticalScroller
          sView.showsVerticalScrollIndicator = NO;
          for (UIView* shadowView in [sView subviews]){
               //to remove shadow
               if ([shadowView isKindOfClass:[UIImageView class]]) {
                    [shadowView setHidden:YES];
               }
          }
     }
}

Tuesday, June 12, 2012

iPhone application lifecycle

Here is an interesting article about iPhone's application lifecycle that I came across.

http://www.codeproject.com/KB/iPhone/ApplicationLifeCycle.aspx

Export and import contacts to iPhone contacts database


Export....
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef person = ABPersonCreate();
CFErrorRef anError = NULL;
ABRecordSetValue(person, kABPersonFirstNameProperty, @"Don Juan", NULL);
ABAddressBookAddRecord (addressBook,person,nil);
ABAddressBookSave(addressBook, &anError);

Import....
ABAddressBookRef addressBook = ABAddressBookCreate();
int noOfPerson = ABAddressBookGetPersonCount(addressBook);
NSMutableArray *allPeople = (NSMutableArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
for(int i=0; i < noOfPerson; i++ ){
ABRecordRef person = [allPeople objectAtIndex:i];
if(ABRecordCopyValue(person, kABPersonEmailProperty) != NULL){  // Checks if email for the contact exists

}
NSString *firstName;
if(ABRecordCopyValue(person, kABPersonFirstNameProperty) != NULL){
firstName = [[NSString stringWithFormat:@"%@", ABRecordCopyValue(person, kABPersonFirstNameProperty)] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSLog(@"%@",firstName);
}

NSString *lastName;
if(ABRecordCopyValue(person, kABPersonLastNameProperty) != NULL){
lastName = [[NSString stringWithFormat:@"%@", ABRecordCopyValue(person, kABPersonLastNameProperty)] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSLog(@"---%@ ",lastName);
}
}



Friday, August 26, 2011

From NSData to CFDataRef


NSData *imageData = UIImagePNGRepresentation(originalImage);
CFDataRef cfdata = CFDataCreate(NULL, [imageData bytes], [imageData length]);

Friday, July 1, 2011

How to set new object properly in objective C

create new object without memory leak.


AnyObject *myObject = [[AnyObject alloc] init]; 
something.property = myObject;
[myObject release]; // no leaks!

Wednesday, June 1, 2011

Bit & Byte difference

For sign digit ]]]]]]]]]]......  -2ˆ(n-1) <<<<<<<>>>>>>>2ˆ(n-1)-1
For unSign digit ]]]]]]......  0<<<<<<<<<<<>>>>>>>>2ˆn-1;
for n dighit divide circle for 2ˆn parts..

Monday, May 30, 2011

Objective C date comparision

if (licenseDictionary == nil){
     return @"Not Registered"; 
}else if([today compare:expDate] == NSOrderedAscending) {
     [gotoButton setEnabled:YES]; return [licenseDictionary objectForKey:@"Name"]; 
} else{
     return @"License Expired";
}

Wednesday, May 25, 2011

Convert sound through Mac terminal

You may use the afconvert tool to convert sounds. For example, to convert the 16-bit linear PCM system sound Submarine.aiff to IMA4 audio in a CAF file, use the following command in the Terminal application:

afconvert /System/Library/Sounds/Submarine.aiff ~/Desktop/sub.caf -d ima4 -f caff -v


You can inspect a sound to determine its data format by opening it in QuickTime Player and choosing Show Movie Inspector from the Movie menu.
Custom sounds must be under 30 seconds when played. if a custom sound is over that limit, the default system sound is played instead.


iPhone support sound formats are
Linear PCM, MA4 (IMA/ADPCM), uLaw or aLaw wAy...

How multitasking works on iPhone

Here is an interesting article about how multitasking works on iPhone

http://gizmodo.com/5512656/how-multitasking-works-in-the-new-iphone-os-40