I have redirected NSLog to a file using the macros.
But I couldn't find a stable way in swift to do that.
As of now I am doing a workaround
I define the following method so whenever I call print in the file it comes here and I write that to a file.
func print(log:String!) {
if let logg = log {
DeveloperConsoleManager.sharedInstance.writeOnConsoleLog(logg)
}
}
But problems with this approach are
1.I will get Extra Argument in Call If I do like below
print("some comments",Obj1,Obj2)
so I have to use like this
print("some comments \(Obj1) \(Obj2)")
2.I will get error like Cannot convert value of type '[AnyObject]' to expected argument type 'String!' If I try to print an object directly
print(obj)
so I have to call the description method of the object
print(obj.description)
3.I have to include the function definition that I have quoted above wherever I want this functionality But in the case of NSLog its globally defined in one place
so Now I am looking for a stable solution to redirect the contents of print in swift to a file
so I can use print as I do normally in swift
Update:
I tried overriding the print but I got Method does not override any method from its superclass