IOS Development Quick Fix
This blog will help developer to fix time consuming issues within a minute.
Wednesday, 7 February 2018
Find the index of object in array in swift 4
userList is array of objects [
User
]
userID
is identity of object, which is use for find index.
let userID = "1"
let
t
empIndex =
u
serList.index(where: { (user:
User
) ->
Bool
in
user.
userID
==
userID
})
t
empIndex is position of object in
u
serList
array.
You may access the object like bellow
let objUser =
u
serList[
t
empIndex
]
Happy coding!
Bhavesh Kumbhani
IOS Software Professional
follow on
Facebook
LinkedIn
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment