Powered By Blogger
Showing posts with label xcode. Show all posts
Showing posts with label xcode. Show all posts

Friday, August 4, 2023

Mobile/Cross Platform App Development with Flutter

Hello everyone,

Once again, after a long long time, I thought to write this article on my new journey with Flutter development. I have just recently started to work as Flutter developer and for that, currently, I'm deep diving with some fresh materials & courses.


Just to give a little bit overview on Flutter for mobile & Mac & web app development, please kindly have a look at below important links which I found during my recent researches.

Dart:

- The most important thing of Flutter app development is DART language which is designed by Lars Bak and Kasper Lund and developed by Google. The programming language can be used to develop web and mobile apps as well as server and desktop applications. It is an object-oriented, class-based, garbage-collected language with C-style syntax.


Flutter:

- Flutter is an open-source UI software development kit created by Google. It is used to develop cross platform applications from a single codebase for any web browser, Fuchsia, Android, iOS, Linux, macOS, and Windows. First described in 2015, Flutter was released in May 2017.

Development Tools:

1. Android Studio
2. Visual Studio Code
3. IntelliJ IDEA
4. XCode (If you're planning to create app for Mac/iOS/iPad devices):
5. Homebrew (for Mac)
6. GiT
7. Cocoapods

Open source libraries:
1. Dart/Flutter Packages
2. Google fonts
3. Google Material Design


Note:
- You can use any of the first 3 IDEs for Flutter development.
- Please have a look at the following link for Flutter's Step by Step guide.


I hope, my this article will help to you to start your journey for Mobile App Development. 
Please keep visiting my blog for my upcoming articles regarding SwiftUI & Flutter development. 


Regards,

Wednesday, June 13, 2012

iPhone/iOS/iPad/Apple Sample Code

 Hi everyone,
Sample code is one of the most useful tools for learning about programming. Here's a collection of links I've found so far. Does anyone know of some other sources for iPhone sample code?

    •    Apple Sample Code: http://developer.apple.com/iphone/library/navigation/SampleCode.html
    •    Apps Amuck 31 days: http://appsamuck.com/
    •    Beginning iPhone Development: http://www.iphonedevbook.com/
    •    Chris Software: http://chris-software.com/index.php/dev-center/
    •    Dave DeLong's downloads: http://www.davedelong.com/downloads
    •    Delicious.com: http://delicious.com/alblue/iphonehttp://web.me.com/smaurice/AppleCoder/iPhone%5FOpenGL/Archive.htmlhttp://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-table-of.html
    •    iPhone Developer's Cookbook: http://code.google.com/p/cookbooksamples/downloads/list
    •    iPhone SDK source code: http://sites.google.com/site/iphonesdktutorials/sourcecode
    •    Joe Hewitt three20: http://joehewitt.com/post/the-three20-project/
    •    Stanford iPhone code: http://www.stanford.edu/class/cs193p/cgi-bin/downloads.php
    •    WiredBob (TabBar in Detail view): http://www.wiredbob.com/blog/2009/4/20/iphone-tweetie-style-navigation-framework.html
    •    BYU Cocoaheads : http://cocoaheads.byu.edu/
    •    Big Nerd Ranch: http://weblog.bignerdranch.com/
    •    Cocoa with love: http://cocoawithlove.com/
    •    Will Shipley: http://wilshipley.com/blog/
    •    mobile.tuts: http://mobile.tutsplus.com/
  
                                            •    Just sample code:
  
    •    Google Code: http://code.google.com/hosting/search?q=label%3Aiphone
    •    iPhone Cool Projects: http://www.apress.com/book/view/143022357x
    •    iPhone Game Projects: http://www.apress.com/book/downloadfile/4419
    •    Learn Objective-C on the Mac: http://www.apress.com/book/downloadfile/4175
    •    iCode Blog: http://icodeblog.com/
    •    Raywenderlich Tutorials: http://www.raywenderlich.com/
    •    OpenGLS: http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-table-of.html

Monday, June 11, 2012

How to delete records from table in iOS SDK?



Hi,
you have to add "sqlite3.dylib " and import the "sqlite3.h" file.

#import "sqlite3.h"

+(BOOL)deleteAllColors
{
    BOOL retVal = FALSE;
    sqlite3 *database = nil;
    sqlite3_stmt *stmt = nil;
    NSString *sql = nil;
   
    NSInteger op_status = sqlite3_open([[ApplicationData returnDatabasePath] UTF8String], &database);
   
    @try
    {
        if (op_status==SQLITE_OK)
        {
            sql = [NSString stringWithFormat:@"delete from Color"];
            op_status = sqlite3_prepare(database, [sql UTF8String], -1, &stmt, nil);
            if (op_status!=SQLITE_OK)
            {
                goto end_of_transaction;
            }
            op_status = sqlite3_step(stmt);
            if (op_status != SQLITE_DONE)
            {
                goto end_of_transaction;
            }
            retVal = TRUE;
        }
    end_of_transaction:
        if (stmt!=nil) {
            sqlite3_finalize(stmt);
            stmt=nil;
        }
        if (database!=nil) {
            sqlite3_close(database);
            database=nil;
        }
        sql = nil;
    }
    @catch (NSException * e)
    {
        // thhrow exception
        if (stmt!=nil) {
            sqlite3_finalize(stmt);
            stmt=nil;
        }
        if (database!=nil) {
            sqlite3_close(database);
            database=nil;
        }
        sql = nil;
    }
    return retVal;
}

Thursday, April 26, 2012

AES Encryption and Decryption

Hello friends,
I'm going to share AES Encryption and Decryption Method for Securely sending your data over the web. Please check the below code :


Step 1: First you have to include these two files into your project.

#include <CommonCrypto/CommonCryptor.h>

@interface NSData(AES)
- (NSData*)AES128Decrypt;
- (NSData*)AES128Encrypt;
@end


#import "NSData+AES.h"

NSString *iv = @"fedcba9876543210";
NSString *key = @"0123456789abcdef";

@implementation NSData (AES)

-(NSData*)AES128Encrypt
{
    char ivPtr[kCCKeySizeAES128 + 1];
    bzero(ivPtr, sizeof(ivPtr));
   
    // fetch iv data
    [iv getCString:ivPtr maxLength:sizeof(ivPtr) encoding:NSUTF8StringEncoding];
   
   
    // 'key' should be 32 bytes for AES256, will be null-padded otherwise
    char keyPtr[kCCKeySizeAES128 + 1]; // room for terminator (unused)
    bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding)
   
    // fetch key data
    [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
   
    NSUInteger dataLength = [self length];
   
    //See the doc: For block ciphers, the output size will always be less than or
    //equal to the input size plus the size of one block.
    //That's why we need to add the size of one block here
    size_t bufferSize           = dataLength + kCCBlockSizeAES128;
    void* buffer                = malloc(bufferSize);
   
    size_t numBytesEncrypted    = 0;
    CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, 0,
                                          keyPtr, kCCKeySizeAES128,
                                           ivPtr/* initialization vector (optional) */,
                                          [self bytes], dataLength, /* input */
                                          buffer, bufferSize, /* output */
                                          &numBytesEncrypted);
   

    if (cryptStatus == kCCSuccess)
    {
        //the returned NSData takes ownership of the buffer and will free it on deallocation
        return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted];
    }
   
   free(buffer); //free the buffer;
    return nil;
}

- (NSData*)AES128Decrypt
{
    char ivPtr[kCCKeySizeAES128 + 1];
    bzero(ivPtr, sizeof(ivPtr));
   
    // fetch iv data
    [iv getCString:ivPtr maxLength:sizeof(ivPtr) encoding:NSUTF8StringEncoding];
   
   

    // 'key' should be 32 bytes for AES256, will be null-padded otherwise
    char keyPtr[kCCKeySizeAES128 + 1]; // room for terminator (unused)
    bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding)
   
    // fetch key data
    [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
   
   
    NSUInteger dataLength = [self length];
   
    //See the doc: For block ciphers, the output size will always be less than or
    //equal to the input size plus the size of one block.
    //That's why we need to add the size of one block here
    size_t bufferSize           = dataLength + kCCBlockSizeAES128;
    void* buffer                = malloc(bufferSize);
   
    size_t numBytesDecrypted    = 0;
    CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt, kCCAlgorithmAES128, 0,
                                          keyPtr, kCCKeySizeAES128,
                                          ivPtr /* initialization vector (optional) */,
                                          [self bytes], dataLength, /* input */
                                          buffer, bufferSize, /* output */
                                          &numBytesDecrypted);
   
    if (cryptStatus == kCCSuccess)
    {
        //the returned NSData takes ownership of the buffer and will free it on deallocation
        return [NSData dataWithBytes:buffer length:numBytesDecrypted] ;
    }
   
    free(buffer); //free the buffer;
    return nil;
}

@end

Step 2: You have to import "Security.framework" into your project.

Step 3: Now, you need to put below code into the class where you want to Encrypt or Decrypt a string and also need to import "NSData+AES.h" file.

- (void)testActuallyEncrypting:(NSString *)hexString
{
    NSLog(@"Encrypted HexString : %@",hexString);

    NSData *data = [self dataFromHexString:hexString];
    NSData *encryptedData =  [NSData dataWithBytes:[data bytes] length:[data length]];
    NSData *decryptedData = [encryptedData AES128Decrypt];
    NSString *decryptedString = [NSString stringWithUTF8String:[decryptedData bytes]];
    NSLog(@"Decrypted String : %@",decryptedString);

    decryptedString = [self addPaddingToString:decryptedString];
    decryptedData = [NSData dataWithBytes:[decryptedString UTF8String] length:[[decryptedString dataUsingEncoding:NSUTF8StringEncoding] length]];
    encryptedData = [decryptedData AES128Encrypt];
    if (encryptedData!=nil)
    {
        NSString *encryptedHexString = [self hexStringFromData:encryptedData];
        NSLog(@"Encrypted HexString : %@",encryptedHexString);

//        NSData *data1 = [self dataFromHexString:encryptedHexString];
//        NSData *encryptedData1 =  [NSData dataWithBytes:[data1 bytes] length:[data1 length]];
//        NSData *decryptedData1 = [encryptedData1 AES128Decrypt];
//        NSString *decryptedString1 = [NSString stringWithUTF8String:[decryptedData1 bytes]];
//        NSLog(@"Decrypted String Testing 123: %@",[decryptedString1 stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" "]]);
    }
}

Step 4 : For step3 , you have to add these three methods into your code.

// For Converting incoming HexString into NSData
- (NSData *)dataFromHexString:(NSString *)string
{  
    NSMutableData *stringData = [[[NSMutableData alloc] init] autorelease];
    unsigned char whole_byte;
    char byte_chars[3] = {'\0','\0','\0'};
    int i;
    for (i=0; i < [string length] / 2; i++) {
        byte_chars[0] = [string characterAtIndex:i*2];
        byte_chars[1] = [string characterAtIndex:i*2+1];
        whole_byte = strtol(byte_chars, NULL, 16);
        [stringData appendBytes:&whole_byte length:1];
    }
    return stringData;
}


// For converting Encrypted Data into NSString after the encryption
- (NSString*)hexStringFromData:(NSData *)data
{
    unichar* hexChars = (unichar*)malloc(sizeof(unichar) * (data.length*2));
    unsigned char* bytes = (unsigned char*)data.bytes;
    for (NSUInteger i = 0; i < data.length; i++) {
        unichar c = bytes[i] / 16;
        if (c < 10) c += '0';
        else c += 'a' - 10;
        hexChars[i*2] = c;
        c = bytes[i] % 16;
        if (c < 10) c += '0';
        else c += 'a' - 10;
        hexChars[i*2+1] = c;
    }
    NSString* retVal = [[NSString alloc] initWithCharactersNoCopy:hexChars
                                                           length:data.length*2
                                                     freeWhenDone:YES];
    return [retVal autorelease];
}
// For padding into a string for required string length
-(NSString *)addPaddingToString:(NSString *)string
{
    NSInteger size = 16;
    NSInteger x = [string length]%size;
    NSInteger padLength = size - x;
    for (int i=0; i<padLength; i++)
    {
        string = [string stringByAppendingString:@" "];
    }
    return string;
}

 By following  all above steps, you will be able to Implement AES Encryption and Decryption. If any one has query then place you it over here.

Thanks and Regards,
Nilesh Prajapati

NSData to HexString and HexString to NSData

Hi everyone,
Here, I've put two different methods for the conversion of "HEXString" to "NSData" and "NSData" to "HEXString".  you may get help from these two. Please ask if you have any query.


- (NSData *)dataFromHexString:(NSString *)string
{  
    NSMutableData *stringData = [[[NSMutableData alloc] init] autorelease];
    unsigned char whole_byte;
    char byte_chars[3] = {'\0','\0','\0'};
    int i;
    for (i=0; i < [string length] / 2; i++) {
        byte_chars[0] = [string characterAtIndex:i*2];
        byte_chars[1] = [string characterAtIndex:i*2+1];
        whole_byte = strtol(byte_chars, NULL, 16);
        [stringData appendBytes:&whole_byte length:1];
    }
    return stringData;
}

- (NSString*)hexStringFromData:(NSData *)data
{
    unichar* hexChars = (unichar*)malloc(sizeof(unichar) * (data.length*2));
    unsigned char* bytes = (unsigned char*)data.bytes;
    for (NSUInteger i = 0; i < data.length; i++) {
        unichar c = bytes[i] / 16;
        if (c < 10) c += '0';
        else c += 'a' - 10;
        hexChars[i*2] = c;
        c = bytes[i] % 16;
        if (c < 10) c += '0';
        else c += 'a' - 10;
        hexChars[i*2+1] = c;
    }
    NSString* retVal = [[NSString alloc] initWithCharactersNoCopy:hexChars
                                                           length:data.length*2
                                                     freeWhenDone:YES];
    return [retVal autorelease];
}


If any one has query then share it over here.

Thanks and Regards,
Nilesh Prajapati
 

Wednesday, April 25, 2012

Video recording in iPhone SDK

Hi,
Here is the integration code for Video Recording in your application. Please check it and follow the steps for integration of it.
You have to add "MobileCoreServices" framework in to your project source.

#import <UIKit/UIKit.h>


@interface AddVideoViewController : UIViewController <UIImagePickerControllerDelegate,UINavigationControllerDelegate>
{
    UIImagePickerController *imagepicker;
}

-(IBAction)startRecording:(id)sender;
@end



#import "AddVideoViewController.h"

#include <MobileCoreServices/UTCoreTypes.h>
#include <MobileCoreServices/UTType.h>

@implementation AddVideoViewController


#pragma mark -
#pragma mark UIView life - cycle


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}

#pragma mark -
#pragma mark UIImagePickerController delegate methods


-(IBAction)startRecording:(id)sender
{
    imagepicker = [[UIImagePickerController alloc]init];
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        imagepicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagepicker.videoMaximumDuration = 10.0; // you can add more time limit for automatic record end
        imagepicker.delegate = self;
        imagepicker.allowsEditing = YES;
        imagepicker.showsCameraControls = YES;
        imagepicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
        imagepicker.videoQuality =  UIImagePickerControllerQualityTypeMedium;
        [self presentModalViewController:imagepicker animated:YES];
    }
    else
    {
        imagepicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
        imagepicker.delegate = self;
        [imagepicker setAllowsEditing:YES];
        imagepicker.modalPresentationStyle = UIModalPresentationFullScreen;
        [self presentModalViewController:imagepicker animated:YES];
    }
}


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSURL *urlString = [info valueForKey:UIImagePickerControllerMediaURL];
    NSData *videoData = [NSData dataWithContentsOfURL:urlString];
    NSArray *Path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentDirectory = [Path objectAtIndex:0];
    NSString *filePath = [documentDirectory stringByAppendingPathComponent:@"video.mov"];
    [videoData writeToFile:filePath atomically:YES];
    UISaveVideoAtPathToSavedPhotosAlbum(filePath, self, @selector(video:didFinishSavingWithError:contextInfo:), filePath);
    [self dismissModalViewControllerAnimated:YES];
}

- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
   
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
   
}

#pragma mark -
#pragma mark memory management

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc. that aren't in use.
}


- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc
{
    [super dealloc];
}

@end


If any one has query then place you it over here.

Thanks and Regards,
Nilesh Prajapati
 

Tuesday, April 17, 2012

How to create UITableView in iOS SDK ?

Hello friends ,
   I'm going to explain you how to create table view by programmatically  in iOS application. Please follow the below code and be sure to include/ set its delegate and datasource property. You have to set "UITableViewDataSource" and "UITableViewDelegate" into the .h[header section] of a class.

UITableView *tblView = [[UITableView alloc]init];
tblView.frame = CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height); // here , you can set you tableview's frame in view.
tblView.delegate = self; // for delegate methods this one need to set compulsary
tblView.dataSource = self;// for datasource methods this one need to set compulsary
tblView.tag = 3; // Tag is used to make the seperation between multiple tables.
[self.view addSubview:tblView]; // place tableview on the main view on which you want to display it.

@optional  // Optional method
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;             
{
    return numberOfsection; // Default is 1 if not implemented
}

@required  // required datasource methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return numberOfRowsInEachSection;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell=[tableView1 dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }
        cell.textLabel.text = @"Hello"; // You can place you content string here what you want to show in each row of the tableview

    return cell;
}

@required // Required delegate methods

- (void)tableView:(UITableView *)tableView1 didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    DetailViewController *viewController = [[DetailViewController alloc]initWithNibName:@"DetailView" bundle:nil];
    [self.navigationController pushViewController:viewController animated:YES];
    [viewController release];
}

Hope, by this you may get idea about to create a table-view pro-grammatically in an application.



Thanks and Regards,
Nilesh Prajapati
 

Monday, April 2, 2012

UIColor using HexCode

Here is the useful method for retrieving UIColor using the HexCode in your application. So, you can use your customize colors in application development.


- (UIColor *)colorWithHexCode:(NSString *)strHexCode
{
     NSString *cString = [[strHexCode stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
   
     // String should be 6 or 8 characters
     if ([cString length] < 6) return [UIColor grayColor];
   
     // strip 0X if it appears
     if ([cString hasPrefix:@"#"]) cString = [cString substringFromIndex:1];
   
     if ([cString length] != 6) return [UIColor grayColor];
   
     // Separate into r, g, b substrings
     NSRange range;
     range.location = 0;
     range.length = 2;
     NSString *rString = [cString substringWithRange:range];
   
     range.location = 2;
     NSString *gString = [cString substringWithRange:range];
   
     range.location = 4;
     NSString *bString = [cString substringWithRange:range];
   
     // Scan values
     unsigned int red, green, blue;
     [[NSScanner scannerWithString:rString] scanHexInt:&red];
     [[NSScanner scannerWithString:gString] scanHexInt:&green];
     [[NSScanner scannerWithString:bString] scanHexInt:&blue];
   
     return [UIColor colorWithRed:(red / 255.0f)
                      green:(green / 255.0f)
                       blue:(blue / 255.0f)
                      alpha:1.0f];
}




Thanks and Regards,
Nilesh Prajapati
 

Saturday, March 31, 2012

iPhone SDKs and APIs

Hi Friends,
I'm going to list out some useful APIs/ SDKs for iOS Application Development environment. So, please make your closure look here.


1) Foursquare Real Time API
The foursquare APIv2 gives you access to all of the data used by the foursquare mobile applications, and, in some cases, even more.
Link : https://developer.foursquare.com/docs/realtime.html

2) Verizon Network APIs
Integrate into your mobile application Verizon's rich array of network functions.
LINK : http://developer.verizon.com/content/vdc/en/verizon-tools-apis/verizon_apis/network-api.html

3) Instagram API
Use these REST and Search APIs to utilize Instagram photos within your app.
Link  : http://instagram.com/developer/

4) Twitter :
 REST API, real-time search index, and streaming API to get tweets in real-time.
Link : https://dev.twitter.com/

5) Dropbox
Dropbox is a free service that lets you bring all your photos, docs, and videos anywhere, and share them easily.
Link : http://www.dropbox.com/developers/releases

6) Bump
Users "bump" their phones to share data within an app.
Link : http://bu.mp/api

7) iPhone ARKit
iPhone ARKit is an Objective-C augmented reality kit for iPhone.
Link : https://github.com/zac/iphonearkit/

8) Core AR
Core AR AR(Augmented reality) framework for iOS, based on a visual code like ARToolKit.
Link : https://github.com/sonsongithub/CoreAR

9) Viewdle Face Recognition
Viewdle's face recognition products to instantly tag friends & share your photos and videos as you create them, from your mobile phone, desktop, or browser!
Link : http://www.viewdle.com/products/ios/index.html

10) PDF Reader
Basic PDF Reader/Viewer for iOS.
Link : https://github.com/vfr/Reader

11) PSGoogleReader
Google Reader class for iOS (iPhone / iPad / iPod Touch).
Link : https://github.com/perspecdev/PSGoogleReader

12) Kal Calendar
A calendar component for the iPhone (the UI is designed to match MobileCal).

Link : https://github.com/klazuka/Kal

13) TouchRSS
TouchRSS is a general purpose RSS and Atom reading framework.
Link : https://github.com/TouchCode/TouchRSS

14) TouchJSON
TouchJSON is an Objective-C based parser and generator for JSON encoded data. TouchJSON compiles for Mac OS X and iOS devices (currently iPhone, iPad and iPod Touch).
Link : https://github.com/TouchCode/TouchJSON

15) ASIHTTPRequest
ASIHTTPRequest is an easy to use wrapper around the CFNetwork API that makes some of the more tedious aspects of communicating with web servers easier. It is written in Objective-C and works in both Mac OS X and iPhone applications.
Link : http://allseeing-i.com/ASIHTTPRequest/

16) Mobile App Tracking
Track all your mobile web and app-2-app installs with one SDK.
Link : https://platform.mobileapptracking.com/#!/advertiser

17) ZipWeather
ZipWeather allows you to look up weather conditions by ZIP Code.
Link : http://www.appsamuck.com/day15.html

18) PhoneGap
PhoneGap is an HTML5 app platform that allows you to author native applications with web technologies and get access to APIs and app stores.
Link : http://www.phonegap.com/docs

19) Route-Me
Route-Me is an open source map library that runs natively on iOS. It's designed to look and feel much like the inbuilt iOS map library, but it's entirely open, and works with any map source.
Link : https://github.com/route-me/route-me

20)MobClix
Mobclix manages everything for you – bringing the best ads to one platform, and handling all the details so you can stay focused on building great apps.
Link : http://www.mobclix.com/developer

If any one has query then place you it over here.

Thanks and Regards,
Nilesh Prajapati
 

Friday, March 23, 2012

Symbolication for iOS Application

Hello all,
Here I'm going to share the Symbolization method for Crash log for finding the excat reason of crash in application. so please follow the steps to get into. These will surely help you.

•    Create new dir on desktop or wherever
   •    Find archive in question in Xcode organizer
    •    Double tap to reveal in finder
   •    Double tap to show bundle contents
   •    Copy .dSYM file and .app file into new dir
   •    cd into new dir
   •    Run this command: atos -arch armv7 -o 'Vimeo.app'/'Vimeo'
   •    Terminal will enter an interactive move
   •    Paste in memory address and hit enter, it will output method name and line number
    •    Alternatively, enter this command: atos -arch armv7 -o 'Vimeo.app'/'Vimeo' To get info for one address only




If any one has query then place you it over here.

Thanks and Regards,
Nilesh Prajapati
 

Wednesday, March 21, 2012

UIDeviceOrientationDidChangeNotification

Hi,
By using below code, you will be able to get notification about your device orientation. You just simply need to include these methods into your controller for which you want to find the device orientation for performing different operations.

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
   
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(didRotate:)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
   
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
}

-(void)didRotate:(NSNotification *)notification
{
    UIInterfaceOrientation newOrientation =  [UIApplication sharedApplication].statusBarOrientation;
    if ((newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight))
    {
    }
    else if (newOrientation == UIInterfaceOrientationPortrait || newOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
    }
}


If you have still any question , you can share it over here.

Thanks and Regards,
Nilesh Prajapati
 

Create JSON without using SBJSON

Hello every one,
This one is to create simple json format without using JSON framework.  This one is just example not a replacement for JSON framework.


+(NSString *)createJSONString:(NSDictionary *) dictionary
{
NSArray *jsonKeys = [dictionary allKeys];
NSArray *jsonKeyValues = [dictionary allValues];

NSString *jsonString = @"{";

for (int j=0; j<[jsonKeys count ]; j++) {
 
NSDictionary *dictFromArray = [jsonKeyValues objectAtIndex:j];
NSArray *keyArray = [dictFromArray allKeys];
jsonString = [NSString stringWithFormat:@"%@\"%@\":",jsonString, [jsonKeys objectAtIndex:j]];
NSArray *valueArray = [dictFromArray allValues];
// to check its empty dictionary
if ([keyArray count] != 0) {
for (int i = 0; i<[keyArray count];i++) {
if (i == 0) {
jsonString =[NSString stringWithFormat:@"%@{ \"%@\": \"%@\", ",jsonString,[keyArray objectAtIndex:i],[valueArray objectAtIndex:i]];
}//to check lost element of single dictionary
else if((i == [keyArray count]-1) ) {
if (j != [jsonKeys count]-1) {
// to check whether last element combined dictionary
jsonString =[NSString stringWithFormat:@" %@ \"%@\":\"%@\" },",jsonString,[keyArray objectAtIndex:i],[valueArray objectAtIndex:i]];
}else
{
jsonString =[NSString stringWithFormat:@" %@ \"%@\":\"%@\" }",jsonString,[keyArray objectAtIndex:i],[valueArray objectAtIndex:i]];
}
}else {
jsonString =[NSString stringWithFormat:@"%@ \"%@\":\"%@\", ",jsonString,[keyArray objectAtIndex:i],[valueArray objectAtIndex:i]];
}
}
}else {
  
if (j != [jsonKeys count]-1) {
jsonString =[NSString stringWithFormat:@"%@{},",jsonString];
}else
{
jsonString =[NSString stringWithFormat:@"%@{}",jsonString];
   
}
}
}

jsonString =[NSString stringWithFormat:@"%@ }",jsonString];

return jsonString;
}


If any one has query then place you it over here.

Thanks and Regards,
Nilesh Prajapati
 

Thursday, February 16, 2012

Thread in Objective C

Here is the Idea about OperationQueue for Thread Management. Please read it carefully this will surely help you.
 NSOperationQueue *updateOrderStatusQueue;
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
                                                                                        selector:@selector(MethodNameWhichYouWantToCallInThread)
                                                                                          object:nil];
                [operation setThreadPriority:NSOperationQueuePriorityNormal];
                [updateOrderStatusQueue addOperation:operation];
                [operation release];


updateOrderStatusQueue is the NSOperationQueue in which you can put multiple threads having different priority of task.

And using below you can also can all the operations in operation queue.

                if (updateOrderStatusQueue != nil) {
                    NSLog(@"Queue Operation Cancelled.");
                    [updateOrderStatusQueue cancelAllOperations];
                }

Thursday, January 20, 2011

UIImagePickerControler

 #pragma mark -
#pragma mark Camera Open Method

-(void)cameraCalling {
    UIImagePickerController *picker;

    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {  
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        picker.cameraOverlayView = lblEvent;
        [picker setShowsCameraControls:YES];
    }
    else
    {
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }
    picker.allowsImageEditing =YES;
  
    [self presentModalViewController:picker animated:TRUE];
  
}



#pragma mark -
#pragma mark imagePickerController Methods

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;
{
    if (!error)
        NSLog(@"Image written to photo album");
    else
        NSLog(@"Error writing to photo album: %@", [error localizedDescription]);


}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
    count ++;
    isRemoved = NO;
    capturedImg = image;
    imgView.image = image;
   
    NSData *imageData = UIImageJPEGRepresentation(image, 1.1);
    NSString *base64String=@"";
    if(imageData)
    {
        base64String=[imageData base64Encoding];
    }
   
    NSDate *date = [NSDate date];
    NSDateFormatter *df = [[NSDateFormatter alloc]init];
    [df setDateFormat:@"MM-dd-yyyy"];
    NSString *str1= [df stringFromDate:date];
    [df setTimeStyle:NSDateFormatterShortStyle];
    NSString *str2= [df stringFromDate:date];
   
    NSLog(@"%@ %@",str1,str2);
    appDelegate.fileName =[NSString stringWithFormat:@"%@ %@",str1,str2];
    [self saveImage:image :appDelegate.fileName];

   
    //UIImageWriteToSavedPhotosAlbum(image, picker, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissModalViewControllerAnimated:YES];

}


Tuesday, October 12, 2010

How to retrieve records from table in iOS SDK?

+(NSMutableArray *)getAllColors
{
    sqlite3 *database = nil;
    sqlite3_stmt *stmt = nil;
    NSString *sql = nil;
    NSMutableArray *arrColors = [NSMutableArray array];
  
    NSInteger op_status = sqlite3_open([[ApplicationData returnDatabasePath] UTF8String], &database);
    @try
    {
        if (op_status==SQLITE_OK)
        {
            sql = [NSString stringWithFormat:@"select color_name,color_code from Color"];
            op_status = sqlite3_prepare(database, [sql UTF8String], -1, &stmt, nil);
            if (op_status==SQLITE_OK)
            {
                while (sqlite3_step(stmt)==SQLITE_ROW)
                {
                    Color *obj_color = [[Color alloc]init];
                    obj_color.color_name = [ApplicationData checkStringValue:stmt withColumnIndex:0];
                    obj_color.color_code = [ApplicationData checkStringValue:stmt withColumnIndex:1];
                    [arrColors addObject:obj_color];
                    [obj_color release];
                }
            }
            else
            {
                goto end_of_transaction;
            }
        }
    end_of_transaction:
        if (stmt!=nil) {
            sqlite3_finalize(stmt);
            stmt=nil;
        }
        if (database!=nil) {
            sqlite3_close(database);
            database=nil;
        }
        sql = nil;
    }
    @catch (NSException * e)
    {
        // thhrow exception
        if (stmt!=nil) {
            sqlite3_finalize(stmt);
            stmt=nil;
        }
        if (database!=nil) {
            sqlite3_close(database);
            database=nil;
        }
        sql = nil;
    }
    return arrColors;
}