Learn Courses My Dashboard

Chat app module 2 lesson 11

I want to know how to extract the exact array.

I’m trying to show the user name of the user in some place if I use the List or foreach it will loop through the user array and show all the users as they are added in contact .

I just want to show the First name and last name of the user in under profile view. Please help m.(current logged in user’s)

This is happening . Also for some reason every time I’m logging out and logging back in currents users are showing again.

That screen shot does not look anything like the layout that Chris Ching specified for the Contacts View in the Chat App course. If you are following the course but adapting the course code to your own Chat Application version then that assumes you know what is required. It’s probably best to follow the course EXACTLY and then later on when the App is finished (still some lessons to come) then you can adapt it to however you like.

wow this was not expected. I understand what you saying, but this is something different I was trying. All I want to know is how to get the specific content from the array I’ll be great full. I’m really enjoying creating this app in my own way. This is is the only thing I am asking I promise I won’t post ever in this community if you want . But please help with this problem

I think you are misunderstanding what I am saying.

Without any context in terms of your code and what you are trying to achieve, it’s a bit hard to know what to suggest.

What does your User model look like?

If you are adapting ContactsListView to suit what you want (which also references ContactRow) can you show the code that you currently have?

gere is a dropbox link

use this one

to sign in.
email is test@test.com
password test123

When I’m uploading the picture from one user login and then logging out.
Then creating the new account and in the profile picture it is showing the other users profile.
Please help

Have you compared your code with the solution code for that Lesson which is available from the Resources section of the course? The Resources link is in the Introduction module of the course.

yes. could you please download it on your computer and run it. I know it won’t take you long to figure out

The reason the local Contacts are not being loaded at the initial login is because the getLocalContacts() function code is the problem.

Change your getLocalContacts() code in ContentViewModel to this:

class ContentViewModel: ObservableObject {
    @Published var users = [User]()
    private var localContacts = [CNContact]()

    func getLocalContacts() {

        DispatchQueue.init(label: "getting local contact").async {
            let store = CNContactStore()
            let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactPhoneNumbersKey] as [CNKeyDescriptor]
            let fetchRequest = CNContactFetchRequest(keysToFetch: keys)

            do {
                try store.enumerateContacts(with: fetchRequest, usingBlock: { contact, success in

                DatabaseService().getPlatformUser(localContacts: self.localContacts) { platformUser in

                    DispatchQueue.main.async {
                        self.users = platformUser
            } catch {

The duplicates are caused by the localContacts array being appended to each time the function is called. Add this code as the first line inside the function getLocalContacts()

localContacts = []  //  Set the localContacts array to be empty each time this function is executed to avoid duplicates.

Hi all,

is the Chat app (SwiftUI) course completed?


In Lesson 31 Chris Ching did say at the end that “this concludes the Chat App for the time being”.

There has been some feedback with suggestions of enhancements and there may be a follow up in the future but from what I understand, Chris is going to concentrate on some other projects for the moment.

Thank you so much.