I am having trouble fetching a row with specific conditions.
I have an Entity called UserAccounts that it contains four attributes: userName, passWord, userFullName, userLevel.
For login, I have to get a passWord that matches the userName. To do this I have two text fields, userNameTF and passWordTF.
I have to fetch a row with an entity (I am using SQL to compare my request) that matches the userNameTF.stringValue and then check if the passWord attribute is equal to passWordTF.stringValue.
Right now I can take arrays of userName and passWord from my Core Data store separately using:
NSArray *userName = [[userAccountsArray arrangedObjects] valueForKey:@"userName"];
NSArray *passWord = [[userAccountsArray arrangedObjects] valueForKey:@"passWord"];
but these two arrays have no relation to each other, and I can’t compare the password with entered username.
I done this before by SQL in VisualStudio using: select "password" from userAccounts where userName = @"username" and then comparing the result with the entered password, but I can’t find a way to fetch a row with an entity, to do something with its attributes.
Well, Finally I found a way solving my problem AGAIN !
Using this code I can retrieve whole attributes of an Entity’s record regarding one specific attribute’s value.
So I can find the passWord related to userName that user typed in the userNameTF textfield !
Anyway, this is my way to solve the problem and I think there is more solutions out there.
Thank you all.