Showing posts with label Swift. Show all posts
Showing posts with label Swift. Show all posts

Wednesday, 10 February 2016

How to declare an Array in Swift


arrayinswift.jpg

Hi Readers!
There are different ways to declare Array in Swift. I will write few examples below:
Example 1:
  1. let a : Array? = ["hello","hi"]
Now in above example this is a constant array. You cannot add/append an element in it.
Example 2: Below both versions of declaring array are same
  1. var a2 = Array<String>()
  2. var a3 = [String]()
Here is not the end….
See full Blog about How to Declare an Array in Swift visit Findnerd.

Thursday, 14 January 2016

How to declare Sets in Swift


declare sets.jpg
Hi Readers!
Let us first understand what Sets means.
Sets
“A set stores unique values of same type in a collection with no ordering. Sets should be used when there is no defined order, such as in Array. Secondly Array can store multiple same values but Sets can't. Sets are distinct."
Hash Values for Set Types
Whatever type you take it should be hashable to be stored in a set. It means that the type must provide a way to compute a hash value. A hash value is an Int value so that same objects can be compared equally, such as if `a == b`, if follows that `a.hashValue == b.hashValue`.
All basic swift types (Int, String, Bool and Double) are hashable by default. Enumerations case values are also hashable by default.
Set Type Syntax
Swift Set is written as `Set` where `Element` is the type that the set will store.
Creating and Initializing an Empty Set
  1. var pets = Set<String>()
Here pets is set which can store String values
Creating a Set with values The example below creates a set called pets to Store String values:
Here is not the end…. To view the full blog about How to declare Sets in Swift visit Findnerd.

Also visir Findnerd for such more tech Blogs like Android,Java, Javascript,C,C++,Ios Development Blogs etc.

Tuesday, 29 December 2015

Load custom cell(Xib) in UITableView in swift


Load custom cell(Xib) in UITableView in swift.jpg
if you would like to Load custom cell(Xib) in UITableView in swift ,you may use the following code ->
  1. func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  2.       return array.count;   //This function returns number of rows in table view
  3.   }


  4. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
Read more about Load Custom Cell in UITableView in Swift at findnerd. You can also learn much more about different programming technologies such as C, Java, PHP, Javascript, iPhone, android questions and answers etc and can also enhance your tech skills.


Tuesday, 30 June 2015

How to show an alert view in Swift Programming Language?

To show an alert in Swift programming language, you need to first import the UIKit framework then use UIAlertController object. A UIAlertController object displays an alert message to the user. To Read complete information about alert view in Swift Programming Language visit FindNerd.
As it is an effective technology forum, so here you can also ask questions & look for various programming queries along with their solutions including android, php, java, c programming questions and answers etc.