1. "Check if this is iPad"

    Fri 27 August 2010

    //Detect if this is an iPad

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){

    //this is iPad


     

    read more
  2. "Encrypt string with certificate from p12 file"

    Mon 14 June 2010

    #import "NSDataAdditions.h"

     

    @implementation Cryptography

     

    const size_t BUFFER_SIZE = 240;

    const size_t CIPHER_BUFFER_SIZE = 1024;

    const uint32_t PADDING = kSecPaddingPKCS1;

     

    - (NSString*) test1

    {

        uint8_t *plainBuffer;

        uint8_t *decryptedBuffer;

        const char inputString[] = "some data";

        int len = strlen(inputString);

        

        plainBuffer = (uint8_t *)calloc(len, sizeof(uint8_t));

        

        strncpy( (char *)plainBuffer, inputString, len);

        

        

        NSString * path = [[NSBundle mainBundle] pathForResource:@"test1" ofType ...

    read more
  3. "Send NSString to windows Web Service through SOAP"

    Mon 14 June 2010

    - (void) Send :(NSString*) tarXML

    {

        recordResults = FALSE;

        

        NSString *soapMessage = [NSString stringWithFormat:

                                 @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"

                                 "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"

                                 "<soap:Body>\n"

                                 "<TestDecrypt xmlns=\"http ...

    read more
  4. "Write NSString to file"

    Mon 14 June 2010

     

    //Method writes a string to a text file

    -(void) writeToTextFile{

    //get the documents directory:

    NSArray *paths = NSSearchPathForDirectoriesInDomains

    (NSDocumentDirectory, NSUserDomainMask, YES);

    NSString *documentsDirectory = [paths objectAtIndex:0];

    //make a file name to write the data to using the documents directory:

    NSString *fileName = [NSString stringWithFormat:@"%@/textfile.txt"

      documentsDirectory];

    //create content - four lines of ...

    read more
  5. "Call selectors from your code. Create own buttons"

    Wed 26 May 2010

    ///////////////////BUTON

    //-- button.h file

    @interface MyButton : NSObject {

    id receiver;

    SEL selector;

    }

     

     

    //-- button.m file

    -(void)addTarget:(id)target action:(SEL)action{

    receiver = target;

    selector =  action;

    }

     

    -(void)touch{

    if (receiver) {

    [receiver performSelector:selector];

    }

    }

     

    //////////////////RECEIVER 

    //-- receiver.m file

     

    ...

    MyButton *mybutton = [[MyButton alloc] init];

    [mybutton addTarget:self action:@selector(actionMethod)];

    ...

     

    -(void)actionMethod{

    //some ...

    read more
  6. "Move alert (UIAlretView)"

    Wed 05 May 2010

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Alert" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

    alert.transform = CGAffineTransformTranslate( alert.transform, 0.0, 100.0 );

    [alert show];

    [alert release];

     

    read more
  7. "Convert image to/from text (Base64)"

    Sun 14 March 2010

    #import "NSDataAdditions.h"

     
     
     

    -(NSString *)getStringFromImage:(UIImage *)image{

    if(image){

    NSData *dataObj = UIImagePNGRepresentation(image);

    return [dataObj base64Encoding];

    } else {

    return @"";

    }

    }
     
    //Convert back 

    NSData *dataObj = [NSData dataWithBase64EncodedString:beforeStringImage];

    UIImage *beforeImage = [UIImage imageWithData:dataObj];

     

    NSDataAdditions.zip (2.80 kb)

    read more
  8. "Check if camera is available"

    Sun 28 February 2010

    if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){

    cameraButton.enabled = NO;

    } else {

    cameraButton.enabled = YES;

    }

    read more

« Page 4 / 13 »