ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

How To Add A Value & Delete A Value In An Array In Swift Programming Language Tutorial

Updated on November 14, 2015

How To Add A Value & Delete A Value In An Array In Swift Programming Language Tutorial

First of all we need to install swift on our our computer.Below is the Link.

https://developer.apple.com/swift/resources/

What are arrays ?

Arrays are where you can store multiple amounts of data,values & Strings.You can also modify,add,delete values new access values in an array.Arrays are extremely useful if you creating an app where you have save & load a lot of data.You can save the data in an array to a text or a dat & many other types of files.

Tutorial to show you how to add a value to an array in swift programming language.

First of all you have to create a array which is done by like this

var fruit: [String]

Then you have to assign values to the array

fruit = ["Strawberry", "Apple", "Orange"]

Then to print the array you just type

print(fruit)

Output Of Code

Strawberry, Apple, Orange

Tutorial to show you how to delete a value in an array in swift programming language

We want to remove the orange value from the array.

var fruit = ["Strawberry", "Apple", "Orange"]

We will do this by using removeAtIndex

fruit.removeAtIndex(2)

print(fruit)

Output Of Code

Strawberry, Apple

Conclusion

With Arrays you can develop apps like database of customers,financial data.sports data and many other subjects.

Arrays can be used very easily and can help beginners to start developing basic but very useful apps.

Arrays Tutorial

Comments

    0 of 8192 characters used
    Post Comment

    No comments yet.

    working