• Skip to main content
  • Skip to primary sidebar

Ravi Shankar

Tweaking Apps

  • About
  • Portfolio
  • Privacy Policy
You are here: Home / Home

iPad App that prints Welcome Message

February 2, 2012 By Ravi Shankar Leave a Comment

Here is an example of writing an iPad app that prints a Welcome message.

Launch Xcode, click File -> New -> New Project.

New Project

Now select the template for the project as Single View Application.

Project Template

Provide the details for your project, like Product Name, Company Name then choose the device for which you are writing the App. Also mark the check box with label as Use Automatic Reference Counting and click the Next button.

Options for New IPad Project

And finally click the Create button to complete the project creation. Now Open the ViewController.xib file and using the Interface Builder designed add two label controls , TextField and Button as shown below.

UI Interface Builder

Label 1 is used for displaying the caption “Enter your Name”, TextField is used for accepting user input, Display button is used for printing the Welcome message in the second label.

Now edit ViewController.h file and add two IBOutlet elements for UITextField and UILabel and IBAction element for button as shown below.

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

{

IBOutlet UITextField *txtName;

IBOutlet UILabel *lblMessage;

}

-(IBAction) btnDisplay;

@end

Then edit ViewController.m file and implement the IBAction function as shown below

– (IBAction)btnDisplay {

lblMessage.text = [@”Welcome “ stringByAppendingString: [txtName text]];

}

This function creates local string by adding “Welcome ” and suffixing it with the name entered in the Textfield.
After completing the coding part, it is time to connect the UI Interface elements with the Object References in code. Select ViewController.xib in the Project Navigator section then click the File’s Owner under Place Holder section. Drag and drop the respective object references to the UI element and connect map the btnDisplay with the Button Touch Down event. The completing mapping of UI Interface elements with Object References is shown below.
UI Elements and Object Reference Mapping

Now the Run the App in iPad simulator by clicking the Run option on the menu bar or by pressing Control + R on the Keyboard.
iPad Simulator
Now entering the name and clicking the Display button will print the Welcome message as shown below.
Welcome App in iPad Simulator

Filed Under: Apple, Develop, ios, iPad Tagged With: App, Apple, iPad, Welcome

How to set Keynote as default application for PPT file

January 27, 2012 By Ravi Shankar Leave a Comment

Mac OS X Lion is pre-installed with OpenOffice software and this is set as the default application for opening any PowerPoint presentation file. Mentioned below are the steps required to set Apple Keynote as the default application for opening PPT file.

  • Launch Finder application on Mac and locate the PPT file.
  • Right click on the PPT file, navigate to Open With and Select Other option.

201201271605.jpg  

  • This would display the following Choose Application window.

201201271607.jpg

  • Scroll down the application list and pick Keynote. Then mark the check box with label as “Always Open With” and click the Open button.

201201271609.jpg

  • This would launch the Keynote application with the selected PowerPoint Presentation file.

Now when ever a PPT file is opened, it will be automatically opened in Apple Keynote.

Filed Under: Apple, Keynote, PowerPoint 2010 Tagged With: Apple, Default, Keynote, Mac OS X Lion, Powerpoint 2010, presentation

Dissecting Objective-C program

January 14, 2012 By Ravi Shankar Leave a Comment

Fotolia_29238788_XS.jpg

We have already seen couple of examples in Objective-C like writing your first program in Objective-C and adding Objective-C classes. Now let us try and analyze the code to learn basic coding on Objective-C program.

Adding Comments

The very basic thing to learn is any programming language is “how to add comments”. In Objective-C you can add comments by adding two consecutive slashes “//” before the text entries. And if you want to add block of comments (more than one line) then you start with /* and end the comment with */

Including Header files

In Objective-C, users can include header files by adding “#import <header filename>”. This would include functions and classes from the header files in to the current program. The examples that has been discussed includes “Foundation” and “Calci” header files.

#import <Foundation/Foundation.h>

#import “Calci.h”

main keyword

int main (int argc, const char * argv[])

“main” is the keyword that marks the beginning line for execution of the program.

Reserving memory

  @autoreleasepool {

The execution code is provided within autoreleasepool and this allocates memory for the program. Now you do not have to explicitly drain the pool, the latest release will automatically drain the allocated memory.

Printing Message

 

  NSLog(@”My First Objective C Program using Xcode!”);

 

NSLog routine is used for printing text messages to the console. The text that needs to be printed is preceded with “@” character. And if you want to print value from a variable then you can use “%i” along with text.

 

NSLog(@”Addition of two numbers %i”, [calculator addition]);

 

Method definition

 

In Objective-C, you can define methods as shown below

 

-(void) setNumber1:(int) n1

-(int) addition

  • “-” refers to the access specifier.
  • void and int specifies the return type for the method.
  • setNumber1 and addition refers to the method name.
  • (int) n1 specifies the type of argument and argument that will be passed to the method.
  • return number1+number2; – “return” keyword is used returning the value from the method.

Filed Under: Apple, Develop, ios Tagged With: Apple, Objective C, Program

Basic tutorial – Adding Objective-C Class using Xcode

January 13, 2012 By Ravi Shankar 1 Comment

Let us see how to add a class in Objective-C by looking at an example that provides basic functionality of adding two numbers. In this example we will be using Xcode for development similar to the earlier post on first program in Objective C using Xcode.

This program is going to have to three main section.

  • Defining Interfaces.
  • Implementing Class methods.
  • Using Objective C class in the program.

Xcode users can add a new class to an existing project by clicking File -> New

201201131923.jpg

This would display the following “Choose a template for your new file” window. Now select Objective-C class from the templates and click Next button.

201201131930.jpg

Then provide a name for the Class some thing like Calci. Also select the Subclass for the class as NSObject and click Next button.

201201131931.jpg

Now this would add two files with extension .h and .m, “Calci.h” and “Calci.m”.

Defining Interfaces

You can define the interface required for adding two numbers in header file (Calci.h). When you add the class file using Xcode, it will be pre-populated with the following code in “Cacl.h” header file.

//

// Calci.h

// Exercise2

//

// Created by Ravi Shankar on 13/01/12.

// Copyright (c) 2012 __MyCompanyName__. All rights reserved.

//

#import <Foundation/Foundation.h>

@interface Calci : NSObject

Write two interfaces for setting the two numbers and another interface for adding the two numbers.

#import <Foundation/Foundation.h>

@interface Calci : NSObject

{

int number1;

int number2;

}

-(void) setNumber1: (int) n1;

-(void) setNumber2: (int) n2;

-(int) addition;

@end

Implementing Methods

After defining the interfaces, implement those interfaces in .m file (Calci.m). When a new class is added, Xcode will pre-populate the .m file with the following code.

//

// Calci.m

// Exercise2

//

// Created by Ravi Shankar on 13/01/12.

// Copyright (c) 2012 __MyCompanyName__. All rights reserved.

//

#import “Calci.h”

@implementation Calci

Now add the following piece of code to add the functionality for settings the two numbers and a method that adds these numbers.

#import “Calci.h”

@implementation Calci

-(void) setNumber1:(int) n1

{

number1 = n1;

}

-(void) setNumber2:(int) n2

{

number2 = n2;

}

-(int) addition

{

return number1+number2;

}

@end

Using Objective C class in the program

After defining and implementing the interfaces in the .h and .m file, now it is time to use the functionality in the program.

  @autoreleasepool {

  

Calci *calculator;

calculator = [Calci alloc];

calculator = [calculator init];

[calculator setNumber1: 35];

[calculator setNumber2: 65];

  

// insert code here…

NSLog(@”Addition of two numbers %i”, [calculator addition]);

  

}

The above code creates an instance of the “Calci” class, then passes the two numbers that needs to be added. Finally [calculator addition] does the addition and the result is printed using NSLog routine.

Filed Under: Apple, ios Tagged With: Apple, Classes, Objective C, Xcode

My fiirst program in Objective C using Xcode

January 11, 2012 By Ravi Shankar Leave a Comment

This tutorial is about writing a basic and simple program in Objective C using Xcode. Let us see an example program that prints “My First Program” in the Console Window.

Xcode new project window

Click the File menu on Xcode, then navigate to New -> New Project. This would display the following Choose a template window. Now select Application under Mac OS X then the Command Line Tool option.

Xcode Command Line Tool

In the Choose options for your new project, enter the name of Product Name and select the Type as Foundation and leave the rest of the option as it is. Click Next to continue with the project creation.

Xcode Choose Project Options

Now specify the location where you want to create the project folder and click Next to continue with the setup.

Xcode Project Creation Folder

This would create a new project window as shown below.

Xcode Project Window

Navigate to Project Navigator and edit main.m file. The Xcode would have already pre-populated code as shown below

//

// main.m

// Exercise1

//

// Created by Ravi Shankar on 11/01/12.

// Copyright (c) 2012 __MyCompanyName__. All rights reserved.

//

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])

{

@autoreleasepool {

// insert code here…

NSLog(@”Hello, World!”);

}

return 0;

}

Change the “Hello World” text to “My First Objective C Program using Xcode” and save the changes (Command + S).

@autoreleasepool {

// insert code here…

NSLog(@”My First Objective C Program using Xcode!”);

}

You can Run the project in Xcode by clicking Product menu and select Run from the menu list.

Xcode Project Build

You can Run Once the build is complete and successful, the output window in the bottom of Xcode will print the message as “My First Objective C Program using Xcode”.

Xcode Console Output Window

Filed Under: Apple, Develop, ios Tagged With: Apple, Objective C, Program, Xcode

Turn off auto replace of hyphens with dashes in Word 2010

December 14, 2011 By Ravi Shankar 1 Comment

AutoCorrect in Word 2010 has a feature which automatically converts two consecutive hyphens in em dash (__). For example when you have words connected with hyphens like June—December (with two hyphens) will be changed to June—December (with em dashes). This feature is by default enabled on Microsoft Word 2010.

Turn off hyphens with dash feature

Users can turn off the auto replacement of hyphens with dashes using the option available as part of AutoCorrect settings. Click the File menu –> Options link and navigate to Proofing Option screen then click the AutoCorrect Options button in the Proofing screen.

image

In the AutoCorrect window, click the AuoFormat As You Type tab and navigate to Replace as you type section.

image

Now unmark the check box with label as Hyphens (–) with dash (—) and click OK button to confirm and save the changes.

del.icio.us Tags: Word 2010,auto,replace,hyphens,dashes,turn off,autocorrect

Filed Under: Office 2010, Word 2010 Tagged With: Auto, AutoCorrect, dashes, hyphens, replace, Turn Off, Word 2010

How to turn off ordinals with superscript in Word 2010

December 12, 2011 By Ravi Shankar Leave a Comment

Microsoft Word 2010 has a feature that automatically replaces ordinals with superscript. But if you do not want this feature then you can turn off using the option provided as part of AutoCorrect settings.

Example of ordinals with superscript

1st displayed 1st

2nd displayed as 2nd

Disable ordinals with superscript

Click the File menu then options link. In the Word Options window, navigate to Proofing section and click the AutoCorrect Options button.

Word Options Word 2010

Click the AutoFormat As You Type tab in AutoCorrect window and navigate to Replace as you type section. Now to disable ordinals with superscript feature, un mark the check box with label as Ordinals (1st) with superscript and then click Ok button to confirm and save the changes.

Ordinals with superscript

del.icio.us Tags: turn off,ordinals,superscript,word 2010,disable,AutoCorrect,proofing

Filed Under: Office 2010, Word 2010 Tagged With: AutoCorrect, Disable, ordinals, Proofing, superscript, Turn Off, Word 2010

How to remove automatic hyperlink in Gmail Signature

December 12, 2011 By Ravi Shankar Leave a Comment

In Gmail, any websites addresses in signature are automatically converted in to hyperlinks. For example, if you have added signature with web address and when you do a compose new message, it will automatically display the web address as hyperlink.

There is no settings that is currently available in Gmail that would turn off these hyperlinks. But there is a work around which can be done for each individual email message.

Gmail Plain Text Clicking the Compose Mail button would open a new compose mail window populated with signature. Now click the Pain Text option above the message text area to remove the hyperlink. In case if you plan to use other formatting option for writing the email then click the Rich formatting option. By this way you can manually remove the hyperlink from the web address in Gmail.
Gmail Rich Text Formatting

Filed Under: GMail Tagged With: Automatic, hyperlink, Remove, Signature, Turn Off

  1. Pages:
  2. «
  3. 1
  4. ...
  5. 34
  6. 35
  7. 36
  8. 37
  9. 38
  10. 39
  11. 40
  12. 41
  13. 42
  14. 43
  15. »
« Previous Page
Next Page »

Primary Sidebar

TwitterLinkedin

Recent Posts

  • Easy Split – Link Expense and User object – Flutter – Day 7
  • Easy Split – Adding Expense page – Flutter – Day 6
  • Easy Split – Showing multiple views – Flutter – Day 5
  • Easy Split – Add screen navigation – Flutter – Day 4
  • Easy Split – Add alert dialog – Flutter – Day 3

Copyright 2021 © rshankar.com