0

I need to migrate my objective-c project to swift project. In my objective-c code, I have a function which includes a @autoreleasepool block:

-(void) doSomething {
   //many things are on going here
   doJobs()

   //@autoreleasepool block here
   @autoreleasepool {
      //access database
      readDB()
      //access backend server
      informServer()
   }
}

In swift code, do I need to treat the @autoreleasepool block specially? If so, how? If no, can I just do things in the sequential way like below in swift?

private func doSomething -> Void {
  //many things are on going here
  doJobs()
  //access database
  readDB()
  //access backend server
  informServer()
}
user842225
  • 5,445
  • 15
  • 69
  • 119
  • Possible duplicate of [Is it necessary to use autoreleasepool in a Swift program?](http://stackoverflow.com/questions/25860942/is-it-necessary-to-use-autoreleasepool-in-a-swift-program). – Martin R Sep 08 '15 at 15:11

1 Answers1

0

You can still use autoreleasepool in Swift:

autoreleasepool {
   // Put your code here 
}

Profile your app to make sure that it actually helps...

Vladimir Kofman
  • 1,983
  • 21
  • 21