Here is an example of what I want to do:
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError)
{
let nm = NetworkModel()
nm.sendlog("file name :AppDelegate , line number : 288", info: " Failed to register: \(error)")
}
current scenario i done that hard coded value line number
and file name
. but is it possible to programatically pick line number
and file name
.
For swift 3 and swift 4:
You can use
#function
,#file
,#line
Here is the implementation of log method in swift : https://github.com/InderKumarRathore/SwiftLog
Below is the snippet
Example
With default values in parameters you can also create a function
which can be used like this
In Swift 2.1
for more info see the documentation