Saturday, August 18, 2012

find db file in users directory in IPhone simulator ios 5


Open your terminal  and write:
chflags nohidden ~/Library/

hit enter 

than your database showing in iphone simulator

Friday, August 17, 2012

Epub Reader

After a lot of search, i finally found a solution to read ePub files for iphone.Few months before i had posted a question in stackerflow.com about a reader for ePub files in iphone.So many peoples answered with their ideas.From the various answers  got from there i finally created a reader for ePub.

Here are the steps to create an ePub reader.

1) create a view with a UIWebView
2) download the EPUB file
3) unzip it to a subdirectory in your app's documents folder .
4) parse the XML file at META-INF/container.xml (if this file doesn't exist the EPUB is invalid) using TBXML, linked above
5) In this XML, find the first "rootfile" with media-type application/oebps-package+xml. This is the OPF file for the book.
6) parse the OPF file (also XML)
7) now you need to know what the first chapter of the book is.
a) each in the element has an id and an href. Store these in an NSDictionary where the key is the id and the object is the href.
b) Look at the first in the . It has an idref attribute which corresponds to one of the ids in (a). Look up that id in the NSDictionary and you'll get an href.
c) this is the the file of the first chapter to show the user. Work out what the full path is (hint: it's wherever you unzipped the zip file to in (3) plus the base directory of the OPF file in (6))
8) create an NSURL using fileURLWithPath:, where the path is the full path from (7c). Load this request using the UIWebView you created in (1).
You'll need to implement forward / backward buttons or swipes or something so that users can move from one chapter to another. Use the to work out which file to show next - the in the XML are in the order they should appear to the reader.

Thanks to Euan(Stackoverflow.com)

You can download the sample code from here

Wednesday, August 15, 2012

Set Background Image for UIView


In iPhone SDK, there is no setBackgroundImage function for setting an background image of an UIView. But actually, this can be done by the setBackgroundColor function. The following code will set the background view to Red.
1self.view.backgroundColor = [UIColor redColor];
So if you want to set a picture as an background image of a view, just initialize an UIColorinstance with an image and set it to the view.
1UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"anImage.png"]];
2self.view.backgroundColor = background;
3[background release];
Please note that you have to set all the items which are in front of the background view toclearColor such that they will not cover the background image.

Validating E-Mail Address

BOOL NSStringIsValidEmail(NSString *checkString)
{
    NString *stricterFilterString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSString *laxString = @".+@.+\.[A-Za-z]{2}[A-Za-z]*";
    NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:checkString];
}

Change iPhone App Name

1. Go to Targets in Xcode
    2. "Get Info" on your project's target (your current silly development name)
      3. Search for "Product Name" under "Packaging". Change the value of that what you want the new program name is going to be.

        http://stackoverflow.com/questions/238980/how-to-change-the-name-of-an-iphone-app

        Clear the UIView


        clears the view

        Option 1:
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextClearRect(context, self.view.bounds);

        Option 2
         for (UIView *view in [self.view subviews]) {
         [view removeFromSuperview];
         }

        Quick Mathematics


        Objective-C does support C-based mathematical functions. All C are written for long variable types. Variables are declared long. Functions must be declared long float or double and any contacts must be written in floating point forms. eg. 1 should be written as 1.0.
        int i; // long int
        double x; // long float
        fabs() – Find the absolute value or unsigned value in parentheses
        results = fabs(x); // fabs(-1.5) = 1.5
        ceil() – Find the ceiling integer; integer just above the value in parentheses; similar to rounding up
        i = ceil(x); // ceil(2.5) = 3
        floor() – find the integer that is below the floating point value in parentheses
        i = floor(x); // floor(2.2) = 2
        exp() – find the expoential value
        pow() – raise a number to the power
        result = pow(x,y); // raise x to the power of y
        result = power(4,2); // raise 4 to the square = 16
        sqrt() – find the square root of a number
        i = sqrt(x); // sqrt(9) = 3

        Step By Step Submission to the App Store


        The online configuration part:

        Step # 1. Create the relevant App ID,  Distribution Certificate & Distribution Provision Profiles. (http://developer.apple.com/ios/manage/overview/index.action) and download them into your keychain.

        Step # 2. Login at https://itunesconnect.apple.com/ with your developer's account.
        (There might be a one time setup for company name and other information if you haven't visited the itunes connect before)

        Step # 3. Go to the "Manage Your Apps". Click on the "Add New App" Button. Enter App Name, SKU Number (Stock-Keeping Unit, nothing technical, just an internal serial for your own track of applications identification) & The Bundle ID which was created from step # 1. Follow the other steps which includes providing application snapshots and other details. After following the forms the application will reach to the "Waiting for Upload" State.

        Step # 4. You will need to Download Application Loader to submit the app to the app store. Run the Application Loader & Authenticate.

        The source code involvement part:

        Step # 5. Open the project in Xcode, make sure that the bundle identifier in the info.plist matches the App ID you created instep # 1.
        Step # 6. Under the Project Menu in Xcode, Go to Edit Project Settings -> Build and navigate to the "Code Signing" Option. Select your developer certificate (which was installed in step # 1) in the Code Signing Identity for the 'Any iPhone OS Device' option.

        Step # 7. From the Xcode's Menu Bar, Select Project -> Set Active SDK -> Device. Then Select Build -> Build.

        Step # 8. If the build is successful, browse the source code directory and look for the build folder, you'll find the directory Debug-iphoneos in it, archive the 2 files present in this directory. *

        Step # 9. Resuming Step #4 From the "Application Loader ", locate the archive and upload it. You'll receive the notification about waiting for the approval after the app has been submitted. *

        Step # 10. Track your application(s) from the iTunes Connect's Manage Your Applications Option for Approvals, submissions etc. (The currently successfully submitted application will get the Status "Waiting for Review" Now)

        * The mentioned actions (have chances to) produce errors and to be handled accordingly to the error notification details.

        Step By Step Submission to the App Store


        The online configuration part:

        Step # 1. Create the relevant App ID,  Distribution Certificate & Distribution Provision Profiles. (http://developer.apple.com/ios/manage/overview/index.action) and download them into your keychain.

        Step # 2. Login at https://itunesconnect.apple.com/ with your developer's account.
        (There might be a one time setup for company name and other information if you haven't visited the itunes connect before)

        Step # 3. Go to the "Manage Your Apps". Click on the "Add New App" Button. Enter App Name, SKU Number (Stock-Keeping Unit, nothing technical, just an internal serial for your own track of applications identification) & The Bundle ID which was created from step # 1. Follow the other steps which includes providing application snapshots and other details. After following the forms the application will reach to the "Waiting for Upload" State.

        Step # 4. You will need to Download Application Loader to submit the app to the app store. Run the Application Loader & Authenticate.

        The source code involvement part:

        Step # 5. Open the project in Xcode, make sure that the bundle identifier in the info.plist matches the App ID you created instep # 1.
        Step # 6. Under the Project Menu in Xcode, Go to Edit Project Settings -> Build and navigate to the "Code Signing" Option. Select your developer certificate (which was installed in step # 1) in the Code Signing Identity for the 'Any iPhone OS Device' option.

        Step # 7. From the Xcode's Menu Bar, Select Project -> Set Active SDK -> Device. Then Select Build -> Build.

        Step # 8. If the build is successful, browse the source code directory and look for the build folder, you'll find the directory Debug-iphoneos in it, archive the 2 files present in this directory. *

        Step # 9. Resuming Step #4 From the "Application Loader ", locate the archive and upload it. You'll receive the notification about waiting for the approval after the app has been submitted. *

        Step # 10. Track your application(s) from the iTunes Connect's Manage Your Applications Option for Approvals, submissions etc. (The currently successfully submitted application will get the Status "Waiting for Review" Now)

        * The mentioned actions (have chances to) produce errors and to be handled accordingly to the error notification details.

        Saturday, August 11, 2012

        Getting the Value of a UITextField as keystrokes are entered?


        On Typing in one Uitextfield can be displayed in another uitextfield 
        
        
        UITextField  * text1=[[UITextField alloc]initWithFrame:CGRectMake(250, 380, 200, 50)];
            text1.userInteractionEnabled=NO;
            text1.textAlignment=UITextAlignmentLeft;
            text1.font=[UIFont fontWithName:FontNormal size:20];
            text1.keyboardType=UIKeyboardTypeDefault;
            text1.backgroundColor=[UIColor whiteColor];
            [self.view addSubview:text1];
            [text1 release];
        
        
        [text1 addTarget:self action:@selector(updateLabelUsingContentsOfTextField:) forControlEvents:UIControlEventEditingChanged];
        
        
        - (void)updateLabelUsingContentsOfTextField:(id)sender {
        
          UiLabel  *greetingLabel.text = [NSString stringWithFormat:@"Hello %@", ((UITextField *)sender).text];
        
        }

        Friday, August 10, 2012

        How To save images to iphone simulator 4.2


        Adding Photo to iPhone simulator photo library
        1) Open and save image on your Desktop
        2) Drag it to simulator, then Safari opens (or browse to the Image in the internet using Safari)
        3) Hold your click on the image
        4)When the pop-up appears, choose Save Image
        5) for iOS Simulator 4.2, do these steps twice to get it work.

        Wednesday, August 8, 2012


        New Fonts in iOS 5.0 - and Some Missing

        Apple iOS 5.0 was released few days ago andinstallation was rather hard. It's still not complete, since I had 500+ apps and restore from iOS 4.3.5 backup was about a total failure. Enough of that, waiting for iOS 5.1 release rather soon.

        Let's look at fonts. Yes, with pictures!

        iOS 5.0 was a huge update in many ways and one of them is built-in font selection. For the first time ever, iPhone and iPad have exactly the same fonts!

        iPad lost two font families (Heiti J, Heiti K), got two new families (Euphemia UCAS, Marion) and 13 additions to already existing font families.

        The following list has been created with the help of FontType application, created by yours truly! (available on App Store)

        ModeliPhoneiPhoneiPadiPad
        Device4.3.35.04.3.25.0

        Academy Engraved LET

        xxx

        American Typewriter
        xxxx
        xxxx

        x
        x

        x
        x

        x
        x

        x
        x

        Apple Color Emoji
        xxxx

        AppleGothic
        xxxx

        Arial
        xxxx
        xxxx
        xxxx
        xxxx

        Arial Hebrew
        xxxx
        xxxx

        Arial Rounded MT Bold
        xxxx

        Bangla Sangam MN
        xxxx
        xxxx

        Baskerville
        xxxx
        xxxx
        xxxx
        xxxx

        x
        x

        x
        x

        Bodoni 72

        xxx

        xxx

        xxx

        Bodoni 72 Oldstyle

        xxx

        xxx

        xxx

        Bodoni 72 Smallcaps

        xxx

        Bodoni Ornaments

        xxx

        Bradley Hand

        xxx

        Chalkboard SE
        xxxx

        x
        x
        xxxx

        Chalkduster

        xxx

        Cochin
        xxxx
        xxxx
        xxxx
        xxxx

        Copperplate

        xxx

        xxx

        x
        x

        Courier
        xxxx
        xxxx
        xxxx
        xxxx

        Courier New
        xxxx
        xxxx
        xxxx
        xxxx

        DB LCD Temp
        xxxx

        Devanagari Sangam MN
        xxxx
        xxxx

        Didot

        xxx

        xxx

        xxx

        Euphemia UCAS

        x
        x

        x
        x

        x
        x

        Futura
        xxxx

        x
        x
        xxxx
        xxxx

        Geeza Pro
        xxxx
        xxxx

        Georgia
        xxxx
        xxxx
        xxxx
        xxxx

        Gill Sans

        xxx

        xxx

        xxx

        xxx

        x
        x

        x
        x

        Gujarati Sangam MN
        xxxx
        xxxx

        Gurmukhi MN
        xxxx
        xxxx

        Heiti J
        STHeitiJ-Lightx
        x
        STHeitiJ-Mediumx
        x

        Heiti K
        STHeitiK-Lightx
        x
        STHeitiK-Mediumx
        x

        Heiti SC
        xxxx
        xxxx

        Heiti TC
        xxxx
        xxxx

        Helvetica
        xxxx
        xxxx
        xxxx

        x
        x

        x
        x
        xxxx

        Helvetica Neue
        xxxx
        xxxx
        xxxx

        x
        x

        x
        x
        xxxx

        x
        x

        x
        x

        x
        x

        x
        x

        x
        x

        Hiragino Kaku Gothic ProN
        xxxx
        xxxx

        Hiragino Mincho ProN

        xxx

        xxx

        Hoefler Text

        xxx

        xxx

        xxx

        xxx

        Kailasa
        xxxx
        xxxx

        Kannada Sangam MN
        xxxx
        xxxx

        Malayalam Sangam MN
        xxxx
        xxxx

        Marion

        x
        x

        x
        x

        x
        x

        Marker Felt
        xxxx
        xxxx

        Noteworthy
        xxxx
        xxxx

        Optima

        xxx

        xxx

        x
        x

        xxx

        xxx

        Oriya Sangam MN
        xxxx
        xxxx

        Palatino
        xxxx
        xxxx
        xxxx
        xxxx

        Papyrus

        xxx

        x
        x

        Party LET

        xxx

        Sinhala Sangam MN
        xxxx
        xxxx

        Snell Roundhand
        xxxx

        x
        x
        xxxx

        Tamil Sangam MN
        xxxx
        xxxx

        Telugu Sangam MN
        xxxx
        xxxx

        Thonburi
        xxxx
        xxxx

        Times New Roman
        xxxx
        xxxx
        xxxx
        xxxx

        Trebuchet MS
        xxxx
        xxxx
        xxxx
        xxxx

        Verdana
        xxxx
        xxxx
        xxxx
        xxxx

        Zapf Dingbats

        xxx

        Zapfino
        xxxx