How to use UIWebView in iOS and swift language
WebView is very easy t use in ios because of ios provide UIWebView. you can find UiWebView in object library .webview is use for load HTML page in ios application.If you load a HTTPS:// URL is apple is very easy to support this type of URL but if you like to load the only HTTP:// apple not support because the only HTTP:// is not a secure URL. If you like to support this type of URL this adds two permission
if you like more understanding watch my video tutorial
Step - 1
create your new Xcode project if don't know how to create Xcode project
Step - 2
you are going to your object library and find UIWebView. UIWebView is drag and drop in your storyboard.
Stp - 3
create an outlet of this web view.
@IBOutlet weak var webview: UIWebView!
Step - 4
write this code in viewDidLoad()
let url = "https://www.google.co.in"
let urlobject = NSURL (string: url)
let request = NSURLRequest(URL: urlobject!)
webview.loadRequest(request)
Note:
https:// URL ios support very easily because of https is very secure URL. if like to support the only HTTP:// URL than follow this step
first open your Info.plist file and add two permission
App Transport Security Settings
Allow Arbitrary Loads = YES
code is same only change is HTTPS to HTTP
let url = "http://myios18.blogspot.in/"
let urlobject = NSURL (string: url)
let request = NSURLRequest(URL: urlobject!)
webview.loadRequest(request)
if you are more understanding about variable open this line
UIWebView example in iOS swift
Swift Dictionaries
Dictionaries are the same array but the array is only store value. dictionaries are store key and value.
Dictionaries are accessed by key, and key is user defined
key is unique identifier if you are not using the unique key then at a time access to two value.
if You are create a empty dictionary using following initializer syntax:
var dictionariesname:Dictionary = [keyType:valueType]()
Example :
var frined:Dictionary = [Int:String]()
if you are create a dictionary with value using following initializer syntax:
var dictionariesname:Dictionary = ["key":"value","key","value"]
Example :
var friendandage:Dictionary = ["parth":"20","hardik":"23","fevin":"22","vijay":"21"]
access dictionaries value by key
Syntax:
dictionariesname["key"]
Example:
friendandage["hardik"]
if you are add same value in dictionary following this syntax:
dictionariesname["key"] = "value"
Example:
friendandage["hiren"] = "25"
if you are update value in dictionary following this syntax:
dictionariesname["oldkey"] = "value"
Example:
friendandage["parth"] = "30"
If you are deleted a value in dictionary following this syntax:
dictionariesname["oldkey"] = nil
Example:
friendandage["fevin"] = nil
If you are print dictionary in reverse following this syntax:
dictionariesname.reverse()
your dictionary is print in reverse order
If you count a value in dictionary in following this syntax:
friendandage.count
If you are remove all value in dictionary following this syntax:
friendandage.removeAll()
Swift Dictionaries
How to Create Array in swift language
The array is used for store multiple values. Array available any type of language.The array is store only values and array is accessed by id.Id is stat by 0,1,2,3,4...
The array is two way to create .first way is an empty array and second array with an array literal.you are store multiple values.The array is most importation for the store .The array is very flexible. you can append array, remove array, insert array etc. watch this video for more understanding.
access array values by 0,1,2,3..
The array is used for store multiple values. Array available any type of language.The array is store only values and array is accessed by id.Id is stat by 0,1,2,3,4...
The array is two way to create .first way is an empty array and second array with an array literal.you are store multiple values.The array is most importation for the store .The array is very flexible. you can append array, remove array, insert array etc. watch this video for more understanding.
empty array
var friend:Array = [String] ()
Creating an Array with an Array Literal
var myFriendArray:Array = ["parth","hardik","fevin","hiren"]
myFriendArray[0]
change values in the array
myFriendArray[3] = "vijay"
append array
myFriendArray.append("king")
insert value in fixed id
myFriendArray.insert("sarag", atIndex: 2)
removeFirst() function only removes first value of array
myFriendArray.removeFirst()
removeLast() function is remove last value of array
myFriendArray.removeLast()
removeAtIndex() function is remove id 2 value of array
myFriendArray.removeAtIndex(2)
the reverse function is used to print the reverse value of the array
myFriendArray = myFriendArray.reverse()
count a value in the array
myFriendArray.count
remove all values
myFriendArray.removeAll()
remove all values
myFriendArray.removeAll(keepCapacity: false)
How to declare Array in swift language iOS
How to declare the variable in swift language
the variable is very importation in any type of language. Swift language is supported by the two type of variable var and let. Var is used to change the value and let is use not change the value (let is constant variable). Every variable declared in two-way. watch this video for more understanding.
Step - 1
First open your Xcode
Step - 2
Select create a new Playground project
if don't know how to create playground visited this line
Step - 3
write your code in the playground
syntax:-
(var type) variablename = values
two way to create a var variables
string
var name = "parth" // first way
var myname:String = "parth" // second way
Integer
var integer = 100
var myinteger:Int = 100
Float
var float = 10.1
var myfloat:Float = 10.1
boolean
var bool = true
var mybool:Bool = true
let is use not change the value (let is constant variable).
same two way to create a let variables
string
let letname = "parth" // first way
let myletname:String = "parth" // second way
Integer
let letinteger = 100
let myletinteger:Int = 100
Float
let letfloat = 10.1
let myletfloat:Float = 10.1
boolean
let letbool = true
let myletbool:Bool = true
how to append a variable in swift language
// string
var appendstring = "parth"
appendstring += "hardik"
var myappendstring:String = "parth"
myappendstring += "hardik"
// integer
var appendinteger = 100
appendinteger += 100 // append variable
appendinteger -= 10 // remove value
var myappendinteger:Int = 100
myappendinteger += 100
// float
var appendfloat = 10.1
appendfloat += 10.1
appendfloat -= 5.5
var myappendfloat:Float = 10.1
myappendfloat += 10.1
myappendfloat -= 5.5
// boolean
var appendbool = true
appendbool = false // your not use binary operator
var myappendbool:Bool = true
myappendbool = false // your not use binary operator
// let variable is not append and remove because let is constant (not change values)
let letappend = 100
letappend += 100 //ERROE
SEE MY PLAYGROUND SCREENSORT:
if you are more understanding about variable open this line
how to declare variable in swift language
how to create a playground in Xcode
see this video
Step - 1
First open your Xcode
Step - 2
Select create a new Xcode playground
Step - 3
-> Enter playground name
Step - 4
Select your project storage location than Next
Step - 5
your playground is created .
see this video
Step - 1
First open your Xcode
Step - 2
Select create a new Xcode playground
Step - 3
-> Enter playground name
Step - 4
Select your project storage location than Next
Step - 5
your playground is created .
if you like my post subscribe my blog And youtube channel
https://www.youtube.com/channel/UCi4Ph-upUMMWcSmUaV_7Nug
https://www.youtube.com/channel/UCi4Ph-upUMMWcSmUaV_7Nug
how to create a playground in Xcode
How to create a new project in Xcode
see this video.
Step - 1
First open your Xcode
Step - 2
Select cteate a new Xcode project
Step - 3
Select IOS -> Application -> single view application
than Next
Step - 4
-> Enter product name
-> Organization name
-> Organization identifier
-> Select Language
-> Select Devices
than Next
Step - 5
Select your project storage location than Next
Step - 6
your project is created .
if you like my post subscribe my blog And youtube channel
https://www.youtube.com/channel/UCi4Ph-upUMMWcSmUaV_7Nug
see this video.
Step - 1
First open your Xcode
Step - 2
Select cteate a new Xcode project
Step - 3
Select IOS -> Application -> single view application
than Next
Step - 4
-> Enter product name
-> Organization name
-> Organization identifier
-> Select Language
-> Select Devices
than Next
Step - 5
Select your project storage location than Next
Step - 6
your project is created .
if you like my post subscribe my blog And youtube channel
https://www.youtube.com/channel/UCi4Ph-upUMMWcSmUaV_7Nug
How to create a new project in Xcode
Subscribe to:
Posts
(
Atom
)