• Skip to main content
  • Skip to primary sidebar

Ravi Shankar

Tweaking Apps

  • About
  • Portfolio
  • Privacy Policy

Mac

Add line numbers in Word 2013, Word 2010 and Word 2007

September 27, 2015 By Ravi Shankar Leave a Comment

Microsoft Word users can add line numbers to a word document using the options available as part of Page Layout menu. In this tutorial we will see the steps for adding line number in Word 2013 and Word 2011 for Mac.

How to add line numbers in Word 2007, Word 2010, Word 2013 and Word 2011 for Mac

Word 2007 Word 2010 and Word 2013

Word 2010 allows users to add line numbers to a word document. This can be done using the Page Layout menu option. For example if you have the following text in your document and you want insert line numbers for each line then you use this feature.

image

To add line numbers for above paragraph, from Home menu click the Page Layout menu option and then navigate to Page Setup section.

Page Layout Menu in Word 2013 and Word 2010

In the Page Layout section, click the drop down arrow next to Line Numbers menu option. This would display the following menu options.

Line numbers in Word 2013 and Word 2010

Now select Continuous from the list available menus and this would insert the line numbers in the Word document as shown below

Document with line numbers in Word 2010 and Word 2013

The other line numbers options includes

  • Restart Each Page – To restart line numbers after each page.
  • Restart Each Section – To restart line numbers after each section.
  • Suppress for Current Paragraph – to remove line numbers for the selected paragraph.

Word 2011 for Mac

Step 1: Open the document for which you want to add line number.

Word 2011 for Mac Layout Menu

Step 2: Click Layout menu and navigate to Text Layout section.

Step 3: Now click the Line Numbers option under Text Layout. This should display the following drop down list.

Word 2011 for Mac Continuous numbers

Step 4: Select Continuous from the Line numbers drop down list to add line numbers. You can also customise Line numbers by use other options in the list.

Show line numbers in document

If you are looking for advanced line number options then click More Line Numbering.

More line numbers option

Display of line number in status bar

If you just want to find out the current line number while editing a document then you can use line number option available as part of status bar for this purpose.

Word 2007, Word 2010 and Word 2013

Microsoft Word 2007 and Word 2010 provides option to display the line numbers in a word document. This would be a useful feature when you want to restrict your content based on the number of lines written in the document. If the status bar does not show the line numbers, then right click on the Status bar and select Line number.

Display line number in status bar in Word 2013, Word 2010 and Word 2007

After selecting Line Number option in the Customize Status Bar context menu, the status bar would display the line number as shown below.

Show line numbers in Word status bar

Word 2011 for Mac

Word 2011 for Mac does not support the display of line number in status bar. This option is available in Window’s version of Microsoft Word but not in Mac OS X.

Also See: How to auto populate random sentences in Word 2010

Filed Under: Apple, Mac, MS Office, Office 2010, Office 2013, Word 2007, Word 2010, Word 2013 Tagged With: Apple, Line numbers, Mac, Page Layout, Show Line numbers, Status Bar, Word 2011 for Mac

Swift – Beginners Tutorial

May 8, 2015 By Ravi Shankar Leave a Comment

Swift is the latest programming language released by Apple for developing OS X and iOS apps.

  • Best of C and Objective-C
  • Adopts safe programming patterns and modern features
  • Supports Playground, a tool for seeing the result immediately.
  • Provides access to Cocoa libraries and can work in conjunction with Objective-C
  • Combines Procedural and Object-Oriented programming.
  • No need to use semicolon at the end of statement. Use it only when you have more than one statement in single line.
  • Swift uses var and let. only mutable variable needs var.
  • Swift uses type inference.
  • Supports unicode characters. You can use any character as variable.
  • Prefer usage of constant (let) for immutable than using var.
  • Optional variables can contain value or nil. – var givenName : String? = “Ravi”
  • Swift’s Switch supports all kinds of datatype and operations and does not need a break statement after each case statement.
  • No need to enclose your expression in brackets with if statements
  • Swift function supports default value for the parameter and variable parameter.
  • Closures are like blocks in Objective-C ( ) -> ( )
  • No need to specify header file in Swift
  • No need to specify base class and there is no universal base class
  • No difference between instance variable and properties
  • Tuples – Grouping of multiple values.
  • Nested multiline comments are allowed.
  • Use typealias to provide different name to an existing type.
  • Swift nil represents absence of value and objective – C nil represents pointer to a non-existent object.
  • Implicitly unwrapped optional let pincode : String! = “E151EH”
  • Provides Assertion to end code execution where certain criteria is not met.
  • Swift’s String is value type and not passed by reference.
  • Supports Optional Binding and Optional Chaining

Variables and Constants

[code language=”swift”]
// Variables and Constants

var myStr = "Swift"
var myValue = 23.1 //(Implicit variable declaration or type inference)
var myDoubleValue: Double = 23 //(Explicit variable declaration)

// let

let myAge = 38
let message = "My age is " + String(myAge) //(Converting value to a String)
let newMessage = "My age is \(myAge)" //(Converting value to a String using backslash or interpolation)

[/code]

Data types in Swift

  • String
  • Int (Range -2,147,483,648 to 2,147,483,648)
  • Double (15 digit precision)
  • Float (6 digit precision)
  • Bool

Fun with String

[code language=”swift”]// String
var movie:String = "Independence Day "
count(movie) // count of string

// Use NSString to format a double or float value
var range = NSString(format: "%.2f", 24.5)

// Concatenate String values
movie += String(range)[/code]

 

Collection Types

Array

[code language=”swift”]// Declarations
// var fruits = ["Orange", "Apple", "Grapes"] – Short declartion
// var fruits:Array = ["Orange", "Apple", "Grapes"] – Long declaration
// var fruits:[String] = [] – Assign empty array

var fruits:[String] = ["Orange", "Apple", "Grapes"] // short declaration with type.

// insert item at index
fruits.insert("Mangoes", atIndex: 2)

// append item to the last
fruits.append("Pine Apple")

// count of array
fruits.count

// remove item
fruits.removeAtIndex(1)

// sort array elements
fruits.sort { (a, b) -> Bool in
a < b
}

// retrieve index using find
find(fruits, "Mangoes")
[/code]

Dictionary

[code language=”swift”]// Dicionary

// Declaration

// var employees = [1:"John",2:"Peter",3:"David"] // Short form

// var employees:Dictionary = [1:"John",2:"Peter",3:"David"] // Long form

// var employees:[Int:String] = Dictionary() // Empty dictionary

var employees:[Int:String] = [1:"John",2:"Peter",3:"David"] //Short form with type

// Add new item to dictionary

employees[4] = "Bob"

// Remove an item using key

employees.removeValueForKey(3)
[/code]

Assignment Operator

  • a = b
  • let (a,b) = (2,3) – supports tuple.
  • Does not return value.

Arithmetic Operators

  • Addition (+), Subtraction (-), Multiplication (*), Division (/)
  • + can be used for string concatenation.
  • % – Returns remainder for both +ve and -ve numbers. Also returns remainder for floating point numbers.
  • Increment and Decrement operators, ++i (i = i + 1), —i (i = i – 1).
  • Supports i++ and i— (increments or decrements after returning the value).
  • Unary Minus and Unary Plus

Compound AssignmentOperator

  • x += 2 is same as x = x + 2.

ComparisonOperators

  • x == y
  • x != y
  • x > y
  • x < y
  • x >= y
  • x <= y
  • === and !== used for testing object references.

Ternary Conditional Operator

  • a = flag ? 10 : 20 (if flag is true then a will updated to 10 and 20 incase it is false).

RangeOperators

  • Closed Range – e.g.:- 1…10, has three dots and includes values from 1 to 10.
  • Half Closed – e.g.:- 1..10, has two dots and includes values from 1 to 9

LogicalOperators

  • NOT ( !x )
  • AND ( x && y )
  • OR ( x || y )

Control Flow

[code language=”swift”]// Control flow

// if else
if fruits[0] == "Grapes" {
println("for breakfast")
} else if fruits[0] == "Apple" {
println("for lunch")
} else {
println("Nothing")
}

// for statements
// exclusive range

for index in 0..<h3><u>Comments</u></h3>[code language="swift"] Single line comments // examples
Multiline comments /* example1
example2 */

[/code]

Function

[code language=”swift”]func sum(number1:Int, number2: Int) -&gt; (Int) {
return number1 + number2
}[/code]

The above function is an example of multiple input parameters. It does the addition of two numbers where number1 and number are arguments of type Int and it returns a value of type int. And a function without parameter looks like this.

[code language=”swift”]
func sum() -&gt; (Int) {
return 10 + 5
}[/code]

The above function is an example of multiple input parameters. It does the addition of two numbers. number1 and number are arguments of type Int and it returns a value of type int. And a function without parameter looks like this. Swift function can also have multiple return values.


Define external parameter name

[code language=”swift”]func sum(addNumber1 number1:Int, withNumber2 number2: Int) -&gt; (Int) {
return number1 + number2
}

println(sum(addNumber1: 10, withNumber2: 20))
[/code]

 

addNumber1 and withNumber are external parameter names for two parameters. And you use # to tell local and external parameter name are same.

[code language=”swift”]
func sum(#number1:Int, #withNumber2: Int) -&gt; (Int) {
return number1 + withNumber2
}
println(sum(number1: 10, withNumber2: 20))[/code]

Function with default parameter value

[code language=”swift”]func sum(number1:Int, withNumber2: Int = 20) -&gt; (Int) {
return number1 + withNumber2
}
println(sum(10))[/code]

The above function has default value for the second parameter.

Variadic Parameters

 

A function with variadic parameters can accept zero or more values. Maximum of one parameter is allowed in a function and it is always last in the list.

[code language=”swift”]
// Variadic parameters
func totalSum(numbers:Int…) -&gt; Int {
var sum = 0
for number in numbers {
sum += number
}
return sum
}
totalSum(1,2,3,4,5)[/code]

Variable and inout parameters

Variable parameters in a function are indicated by var keyword and the scope is available only within the function. If you want to access the modified variable value outside the function then you specify them as inout parameter. And prefix with & while passing the parameter in the function call.

[code language=”swift”]
// inout parameters
var employee = "Ravi"

func greetings(inout employee:String) {
employee += "!"
}
println(greetings(&amp;employee))
println(&amp;employee)[/code]

Filed Under: Apple, ios, Mac Tagged With: Apple, Quick Reference, Swift

payworks SDK integration in Swift

March 26, 2015 By Ravi Shankar Leave a Comment

payworks mPOS helps app developers to integrate their App with card reader. In this tutorial, we will see a sample app that integrates payworks mPOS using Swift.

Download the source code from github

Select New Project and choose Single View Application from the template.

201503260807.jpg

In the Project Options window, provide a product name and make sure to select Language as Swift. Click Next and Save the project.

201503260812.jpg

In the Project Navigator, select Main.storyboard and unmark check box “Use Size Classes” in the File Inspector. Then click Disable Size Classes button as this app is only designed for iPhone

201503260825.jpg

UI Design

Design the user interface as shown below.

  • Label to shown caption as Amount
  • TextField for entering the amount
  • Button to Charge Amount.
  • Label to display the status message.

201503260840.jpg

Just to reflect the purpose of this little app, let us rename the ViewController.Swift to ChargeViewController.swift. Make the corresponding changes to Class name as well in Identity Inspector.

Integrate mPOS SDK

We are going to add mPOS SDK to this project using CocoaPods by following the instructions here.

Close your Xcode project, launch Terminal window and and navigate to project folder.

201503260927.jpg

Create a new Podfile with the following statements

201503260929.jpg

Doing a pod install should download the mPOS SDK’s to your project folder.

201503260936.jpg

Now navigate to your project folder and open the file with extension as .xcworkspace. The Pods folder in the project navigator should contain the mPOS framework.

201503260956.jpg

Objective-C Bridging

We need to create a bridge file to call the objective-c related framework files in our Swift app. The easiest way to do this is to create new Objective-C file in your project.

Right click on your project folder, select New File.

201503260959.jpg

In the Choose a template screen, select Objective-C and click Next.

201503261005.jpg

Provide a name for the Objective-C file and save the file.

201503261007.jpg

Now you will prompted whether you would like to configure an Objective-C bridging header. Click Yes to create the bridging header file.

201503261007.jpg

As the header file is created, we do not need the temp objective-c file, you can delete this file.

201503261021.jpg

Navigate to Bridging-Header file in Project navigator and the following lines.

@import Foundation;

#import

Now you can make sure every thing works fine by doing a build. Also make sure to add the additional steps as mentioned in the instruction page for Miura Readers. Navigate to info.plist and add supported external accessory protocols and Required background modes keys.
201503261032.jpg
mPOS integration
Create two IBOutlets, one for TextField and another for Message Label.

  @IBOutlet weak var amountTxtField: UITextField!

@IBOutlet weak var messageLabel: UILabel!

  

Use the connection inspector to connect the IBOutlets with the controls.

201503261037.jpg

In order to connect with mPOS SDK, you need to register and get the merchant credentials, You can do this by registering here. After receiving the credentials create two constants to hold the identifier and secret key.

  let MERCHANT_IDENTIFIER = “YOUR_MERCHANT_IDENTIFIER”

let MERCHANT_SECRET_KEY = “YOUR_SECRET_KEY”

201503261049.jpg
Now add the following IBAction method to ChangeViewController.swift and connect the IBAction with the button.

  @IBAction func chargeCard(sender: UIButton) {

  

let amount:NSDecimalNumber = NSDecimalNumber(string: self.amountTxtField.text)

  

let transactionProvider:MPTransactionProvider = MPMpos .transactionProviderForMode( MPProviderMode.MOCK, merchantIdentifier: MERCHANT_IDENTIFIER, merchantSecretKey: MERCHANT_SECRET_KEY)

  

let template: MPTransactionTemplate = transactionProvider.chargeTransactionTemplateWithAmount(amount, currency: MPCurrency.EUR, subject: “subject”, customIdentifier: “customIdentifier”)

  

let paymentProcess:MPPaymentProcess = transactionProvider.startPaymentWithTemplate(template, usingAccessory: MPAccessoryFamily.Mock, registered: { (let paymentProcess:MPPaymentProcess!, let transaction:MPTransaction!) -> Void in

  

}, statusChanged: { (let paymentProcess:MPPaymentProcess!, let transaction:MPTransaction!, let paymentProcessDetails:MPPaymentProcessDetails!) -> Void in

  

self.messageLabel.text = self.formatMessage(paymentProcessDetails.information)

  

}, actionRequired: { (let paymentProcess:MPPaymentProcess!, let transaction:MPTransaction!, let transactionAction:MPTransactionAction, let transactionActionSupport:MPTransactionActionSupport!) -> Void in

  

}) {(let paymentProcess:MPPaymentProcess!, let transaction:MPTransaction!, let paymentProcessDetails:MPPaymentProcessDetails!) -> Void in

  

self.messageLabel.text = self.formatMessage(paymentProcessDetails.information)

}

}

  

func formatMessage(information:AnyObject) -> String {

let temp = (information[0] as NSString) + “\n”

return temp + (information[1] as NSString)

}

Since I don’t have a real reader to try this demo, I have used Mock mode for the transaction provider and payment process
  let transactionProvider:MPTransactionProvider = MPMpos .transactionProviderForMode( MPProviderMode.MOCK, merchantIdentifier: MERCHANT_IDENTIFIER, merchantSecretKey: MERCHANT_SECRET_KEY)

  let paymentProcess:MPPaymentProcess = transactionProvider.startPaymentWithTemplate(template, usingAccessory: MPAccessoryFamily.Mock, registered:

Now you are good to try this demo by entering an amount and tap the Pay button. The trisection status will be displayed in the message label.

201503261058.jpg
You can also test your solution by entering different amount as mentioned in the test page.
201503261101.jpg
Download the source code from github

Filed Under: Apple, iPhone, Mac, Programming Tagged With: Apple, integration, payowrks, Swift

How to reduce size of document with images in Microsoft Word

October 12, 2014 By Ravi Shankar Leave a Comment

Microsoft Word provides users with the option to reduce the file size of the document with images. In this tutorial, we will see the technique of reducing the file size in Word 2013 and Word 2011 for Mac.

Reduce images size in Word 2013

Word 2013 users can use the Compress Pictures option available as part of Format Picture to compress the images in the document.

Step 1: Click the Format menu in Microsoft Word 2013. Please note the Format menu will be available only after selecting the image on the document.

image

Step 2: In the Format menu, navigate to Adjust section and click the Compress Pictures option. This should display the following Compress Pictures window.

image

Now you can choose the desired option under Compression options and Target Output. Let say you want to only share the document with other users using email, then go for “E-mail (96 ppi): minimize document size for sharing”.

Step 3: After selecting the required options, click Ok button to apply the changes to images.

Compress images in Word 2011 for Mac

Step 1: Select the image in the document and click Format Picture menu.

201401021315.jpg

Step 2: Under Format Picture menu, click the Compress Option. This should display the following Reduce File Size screen.

201401021317.jpg

Step 3: Now choose the Picture Quality drop down to apply appropriate picture quality as per your needs. You can apply the changes to all the pictures in the file or just Selected pictures

Step 4: Click OK button to apply the changes to the document.


Filed Under: Apple, Mac, MS Office, Office 2013, Word 2013 Tagged With: Apple, compress images, document file size, Mac, Office 2013, reduce file size, Word 2011 for Mac, Word 2013

Insertion Sort

July 3, 2014 By Ravi Shankar 2 Comments

Insertion Sort algorithm does the following

  • Keeps the sorted numbers from left to right.
  • Compares the left with right and interchanges the number if left is greater than right.

Here is code snippet of Insertion Sort in Swift.

[code language=”swift”]var inputArr:[Int] = [Int]()

// generate random numbers
for rIndex in 0..&lt;10 {
inputArr.append(((Int(arc4random()) % 100)))
}

func insertionSort(var inputArray :[Int]) -&gt; [Int] {
var jIndex:Int,kIndex:Int

for kIndex in 1.. 0 &amp;&amp; inputArray[jIndex-1] &gt;= temp ) {
inputArray[jIndex] = inputArray[jIndex-1]
–jIndex
}
inputArray[jIndex] = temp
}

return inputArray
}

insertionSort(inputArr)[/code]

Filed Under: Mac, Programming, Xcode Tagged With: algorithm, insertion Sort, Swift, Xcode

How to change bluetooth device name of iPhone/iPad/Mac

October 23, 2013 By Ravi Shankar Leave a Comment

Change bluetooth name for iPhone, iPad and Macbook Pro.

In this tutorial we are going to cover the steps required to change the device name that appears while discovering bluetooth enabled Apple devices. For example when you are trying to pair iPhone with MacBookPro, the Set up Bluetooth Device screen on Macbook Pro would display the following

Bluetooth Set up Wizard

Where “Ravi Shankar’s iPhone” is the name of my iPhone. Similarly on iPhone under Bluetooth settings, you should find the MacBook Pro’s name.

Bluetooth Paired device name on iPhone

How to change bluetooth device name for iPhone

Step 1: Tap the Settings icon on the Home screen.

Step 2: Under Settings, Tap General options.

General Settings on iPhone

Step 3: Navigate to About option under General Settings.

General Settings on iPhone

Step 4: In the About screen Tap Name option. This should provide an option to change the name of your iPhone.

201310231603.jpg   Change name on iPhone  

How to change bluetooth device name for iPad

Follow the same steps mentioned for iPhone (Step 1 to 4) to reach the Name screen on your iPad.

Change iPad bluetooth name

How to change bluetooth name for Macbook Pro

Step 1: Click the Apple icon and select System Preferences from the menu list

System Preferences on Macbook Pro

Step 2: In System Preferences screen, navigate to Internet & Wireless section and click Sharing option.

Sharing option on Mackbook Pro

Step 3: Click Edit button under Computer Name section and provide your preferred name.

Computer name on Macbook Pro

Change bluetooth computer name on Macbook Pro

Step 4: Click OK button to confirm and save the changes.

Also See:

1. Turn On/Off bluetooth on iPad

2. Rename bluetooth devices on Macbook Pro

3. What is Control Center in iOS 7

Filed Under: Apple, iPad, iPhone, Mac, Mac OS X Tagged With: Apple, Bluetooth, device name, iPad, iphone, Mac

How to add YouTube video to Word 2011.

August 8, 2013 By Ravi Shankar Leave a Comment

In this tutorial we are going to see the steps required for adding videos from Youtube in Word 2011 for Mac. In Office 2011 you can not directly embed YouTube video URL. If you want to insert videos then you need to the following.

  • first download the video using third party software
  • Insert the downloaded file using Media option in Word 2011.

Download YouTube Video using third party software.

Step 1: Open http://www.mediaconverter.org/ for downloading the video from YouTube (You can also use other third party software).

201308080828.jpg

Step 2: Click Enter a link option and add the YouTube URL then click Ok button.

201308080839.jpg

201308080839.jpg

Step 3: In the media converter wizard, click go to the next step button.

201308080842.jpg

Step 4: Select the type output file. Since this is on Mac, we have gone with MP4 format. After selecting the output file format, click start conversion button.

201308080846.jpg

You should see the following status message on the media converter page.

201308080849.jpg

Step 5: Click the download link to download the converted file on to your Mac.

201308080850.jpg

Insert downloaded video file in Word 2011

Step 1: Launch Word 2011, click Insert menu and select Movie from file under Movie.

201308080856.jpg

Step 2: In the “Insert Movie or Audio” screen, select downloaded YouTube video and click Choose button.

201308080857.jpg

Now you should be able to see and play the video in your document.

201308080859.jpg

Filed Under: Apple, Mac, MS Office, Videos Tagged With: Apple, embed videos, Videos, Word 2011, YouTube

Reduce the time taken for searching iOS documentation using Xcode

August 1, 2013 By Ravi Shankar Leave a Comment

This tip is for iOS developers who want to reduce the time taken while searching iOS documentation using Xcode. Documentation under the Xcode organiser window by default shows information on OS X as well. If you are not a Mac developer then you can turn off the documentation related with OS X.

Step 1: Launch Organizer window in Xcode and navigate to Documentation tab.

201308012017.jpg

Step 2: In the Documentation window, navigate to the Search Documentation option and click the arrow pointing downwards under the search icon.

201308012022.jpg

Step 3: Now select Show Find Options from the menu list.

201308012024.jpg

201308012025.jpg

Step 4: Navigate to the Find in list box then deselect “OS X 10.7 Core Library” and “OS X 10.8 doc set”.

This would exclude the OS X library while using the documentation search on Xcode.

Filed Under: Apple, Mac, Xcode Tagged With: Apple, Documentation, search, Xcode

  • Go to page 1
  • Go to page 2
  • Go to Next Page »

Primary Sidebar

Recent Posts

  • We have blocked all requests from this device – Firebase Phone Authentication
  • iPhone is not available error message in Xcode
  • Clear CocoaPods cache, re-download and reinstall all pods
  • PDFKit – View, Annotate PDF file in Swift
  • Tab Bar Controller with WebView

Archives

  • September 2020
  • April 2020
  • December 2019
  • November 2019
  • October 2019
  • February 2019
  • October 2017
  • June 2017
  • May 2017
  • March 2017
  • September 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • October 2013
  • August 2013
  • July 2013
  • June 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • November 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • April 2011
  • March 2011
  • January 2011
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • July 2009
  • March 2008

Copyright 2020 © rshankar.com