Wednesday, 4 April 2018

Swift Basics

var for variables
let for constants
example
var a = 2
var a :Int = 2


if condition
{
code

}


Switch statement
Switch valuetoconsider
{
case value1:
case value2,value3:
default:
}


Loops
for counter in lower...upper
{

}

for(index in 1...5)
{
print(index)

}
o/p 12345


while loop
while condition{
some code
}


repeat while loop
repeat{
code
}while condition

functions
func name()
{
code
}


func name() -> Datatype
{

return ;
}

arguments
func name(argumentLabel parametername:datatype)
{
}




How to create a object for Class


class name{
func test()
{

}

}
create a class object
let objectOne = name()




Inheritance

class subclass : name{

 override func test()
 {


 }
}

Optionals
--------
var title:string?
It means it could be nil or could contain a string
var author:person?
where person is a class
if let actualTitle : post.title{
print("hellso string is not empty");
print(post.tilte! +"zzzz") //This is force wrapping
}

How to resize a view
Click and hold command and then click =

comand + enter to remove the split screen

How to print name and age
print("\(name) , \(age)")

power operators in swift
pow(height , 2) which is height * height
Convert double to string
String(value)
for number in arrauOfNumbers
for number in 1..<10 where number %2==0
{
print(number)
}
we get all even numbers till 9




Hold on command and click on method to read doc of method
Hold on option key and hover on method to read doc of method
By default all the components have tag 0
label.text = "\(intvalue)"
How to use lib project written in objctectve c in our swift project
copy .h , .m ,.bundle in to supporting files
then in bridging file write import .h
Then directly use where ever needed
option +ctrl+i to reindent code (select all and do)
creating enums
enum CarType
{
case Sedan
case Coupe
case Hatchback
}
var typeOfCar : CarType = .Coupe
convinience init(color : String)
{
self.init()
colorProp = color
}
designated initializers needs all the properties
inheritance
class selfDrivingCar : Car
{
}
Cocoapods.org

Tuesday, 3 April 2018

Onclick Listener for a button in IOS

Step 1

Create a new Project in X Code by selecting File --> New Project and then required options

Step 2

Create a new File by selecting File --> new File --> CoCoa Touch Class.Select option of create Xib in the same window
Here three files will be generated sample.h , sample.m and sample.xib

Step 3

Sample.xib is like xml file in android.Open it and drag and drop the required component Button

Step 4

Open the AppDelegate.m file then load the required Xib file (Sample.xib) in the didfinishlaunchingwithoptions method
If you run should be able to see the designed interface

Step 5

Create outlets by selecting a component in xib file and dragging it to the interface .h file

Step 6

Create a method like buttonPressed in sample.controller
like
-(IBAction)buttonPressed:(id)sender
{


//do the necessary things
}


Step 7

Go to xib file right click on the button and then select action like TouchDown and drag it to the fileowner where you can see the method which you have defined

Step 8

Build and Run

Monday, 2 April 2018

UITextField Objective C

Step 1

Create a new Project in X Code by selecting File --> New Project and then required options

Step 2

Create a new File by selecting File --> new File --> CoCoa Touch Class.Select option of create Xib in the same window
Here three files will be generated sample.h , sample.m and sample.xib

Step 3

Sample.xib is like xml file in android.Open it and drag and drop the required component TextField

Step 4

Open the AppDelegate.m file then load the required Xib file (Sample.xib) in the didfinishlaunchingwithoptions method
If you run should be able to see the designed interface

Step 5

Create outlets by selecting a component in xib file and dragging it to the interface .h file

Step 6

We have to use TextField delegate UITextFieldDelegate to use the necessary methods of textfield like editing ,keyboard up down etc

Step 7

Implement the protocol UITextFieldDelegate in the .h file
like
@interface SampleController:UIViewController<UITextFieldDelegate>


Step 8

In SampleController.m you can use delegate methods
example
-(BOOL)
textFieldShouldReturn:(UITextField *)textfield
{

NSLog(@"entered text %@",self.nameTextView.text);
[self.nameTextView resignFirstResponder];
return YES;
}

Step 9

Create delegate and referencing delegate by selecting component in xib file and dragging it to the Files owner .Later right click it and create a referencing outlet

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...