ios - What is the swift equivalent of makeObjectsPerformSelector? -


in objective-c i'm using code remove sub-views:

[self.view.subviews makeobjectsperformselector:@selector(removefromsuperview)]; 

but how use in swift? saw apple documentation use method in swift

func makeobjectsperformselector(_ aselector: selector) 

but when try it, error: 'anyobject[]' not have member named 'makeobjectsperformselector'

are there ways remove sub-views in swift?

updated swift 2.0 (xcode 7)

use foreach:

self.view.subviews.foreach { subview in     subview.removefromsuperview() } 

or this:

view.subviews.foreach { $0.removefromsuperview() } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -