Database Reference
In-Depth Information
"about" : "Dolore reprehenderit ... voluptate consectetur.\r\n"
},
Note: You can vary the amount and type of data the app imports from the
seed.json file by modifying the amountToImport and addSalesRecords
constants located at the top of AppDelegate.swift . For now, leave these
constants set to their default values.
In terms of performance, the text showing the employee names, departments,
email addresses and phone numbers is inconsequential compared to the profile
pictures, which are large enough to potentially be impacting the performance of the
list.
Now that you've measured the problem and have a baseline for future comparisons,
you'll make changes to the data model to reduce the amount of RAM in use.
Making changes to improve performance
The likely culprit to the high memory usage is the employee profile picture. Since
the picture is stored as a binary data attribute, Core Data will allocate memory and
load the entire picture when you access an employee record. This will happen even
if you only need to access the employee's name or email address!
The solution here is to split out the picture into a separate, related record. In
theory, you'll be able to access the employee record efficiently, and then take the
hit for loading the picture only when you really need it.
To start, open the visual model editor by clicking on
EmployeeDirectory.xcdatamodeld .
Start by creating an object, or entity, in your model. In the bottom toolbar, click
the Add Entity plus (+) button to add a new entity.
Name the entity EmployeePicture . Then click the entity and make sure the third
tab is selected in the Utilities section. Change the class to
EmployeeDirectory.EmployeePicture ; you need to give the full class name with
the app's name as the namespace for it to work with Swift.
Search WWH ::




Custom Search