Question: the issue i'm having is when i load this
UIViewController.removeSpinner(spinner: self.view) 

it gives me a blank black view, and i don't know how to access sv variable from the button function:

let sv = UIViewController.displaySpinner(onView: self.view)

im using this extintion to load the spinner and remove
<http://brainwashinc.com/2017/07/21/loading-activity-indicator-ios-swift/>

what im actually trying to do:

1- get url of voice message.

2- run the spinner to load the player.

3- play.

4- remove spinner if the observer find it ended.

here is my code:

```
 @IBAction func vnClick(_ sender: UIButton) {
    let vnInfo = itemss[sender.tag]
    print(vnInfo.vnUrl)
    let sv = UIViewController.displaySpinner(onView: self.view)
    if let url = NSURL(string: vnInfo.vnUrl) {
        player = AVPlayer(url: url as URL)
        player.play()
        //check if ended playing to remove spinner
        NotificationCenter.default.addObserver(self,  selector:#selector(playerDidFinishPlaying(note:)),name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem)

    }
}
@objc func playerDidFinishPlaying(note: NSNotification) {
    UIViewController.removeSpinner(spinner: self.view)
}

```

Answer: 
```
public moderlist=[];
public notification1=[];
public createdon1=[];
public notificationlabel:any=[];
public createdonlabel:any=[];
public fourNotification:any=[];
    getAllNotifications() {
         debugger;
    this.RedBenchService.getNotifications().subscribe(
      results => {
        // this.moderlist
          debugger;
        this.moderlist= results;
        for(let i=0; i<=4;i++)
                {

                   debugger;
                  this.fourNotification.push(this.moderlist[i]);
                  }

              },
      error => {
        console.log(error);
      });
  }

```
Change the logic in the for loop as follows. 

```
if(this.moderlist.length >= 4){
     for(let i=this.moderlist.length-1; i>=this.moderlist.length-4;i--) {
            this.notification1.push(this.moderlist[i].Notification1);
            this.createdon1.push(this.moderlist[i].CreatedOn);
        }
     }

```