0

I have a struct class which I store Datas about phone and app properties like screenResolution, PhoneModel, ApplicationInstalledDate, wifiDetailInfo. It will be declared just one time when app opens. I want to write functions for every property because there will be like 30 property and in init method I want to call every function to declare properties. As I searched, I can't do it directly like

property = self.function()

So I declare functions as private static as you can see in below code.

My questions are;

1-) When I declaring and calling functions like that will they work as async? If not, will It be a performance problem because I'm calling these on app start (AppDelegate) and I'm not sure If they affect app opening time.

2-) In addition, my app needs to be secure. Maybe It is a silly question but something came to my mind. If I declare a function static even it is private, Is it more easy to be reach when reverse engineered and trying to change or get some data?

struct DeviceDataModel {
    let applicationInstalledDate: String
    //Continue

    init?(){
        applicationInstalledDate = DeviceDataModel.getApplicationInstalledDate()

    }
    private static func getApplicationInstalledDate() -> String{
        let urlToDocumentsFolder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last!
        //installDate is NSDate of install
        return (try! FileManager.default.attributesOfItem(atPath: urlToDocumentsFolder.path)[FileAttributeKey.creationDate] as! String)
    }
}
Arasuvel
  • 2,971
  • 1
  • 25
  • 40
Mr Some Dev.
  • 315
  • 4
  • 19

1 Answers1

1

No function is asynchronous, unless you define it as such. Thus if those functions are defined by you, and you are not making them asynchronous (by performing the execution on the background thread and calling the callback to notify on its completion), they are not asynchronous. Check this article and this article on some insights on async methods.

Regarding the second question - access modifiers are about encapsulation and abstraction in object oriented programming - concepts that have very little to do with security of the app - I don't think that making a function private instead of internal (without a modifier) can make it harder to reverse engineer the code.

Only possible scenario that I can imagine that can affect this is probably using public/open, because then those functions would be accessible outside of the module without any reverse engineering tools - but that would require the attacker to add that app as a dependency (which he can do, but I believe there are more elaborated ways to reverse engineer app code).

Milan Nosáľ
  • 19,169
  • 4
  • 55
  • 90