Community

Community Forums

Where our customers, developers, and more can come together to help each other with both general and technical questions about our products and services.

String(stringInterpolationSegment: issue in your sample swift project

wulong yang

hi, I have a question about your below linked sample project.

as it worked before for swift 4.2 , but today after I update my xcode to latest xcode ,swift 5 ,this line not working anymore.

in refreshMessageCenterBadge()

about this line 

String(stringInterpolationSegment:UAirship.inbox().messageList.unreadCount)  ,it show Extranuous argument label 'stringInterpolationSegment:" in call this error message.

 

so can you help what is correct writing for this line now?

 

 

 

 

https://github.com/urbanairship/ios-library/blob/master/SwiftSample/SwiftSample/AppDelegate.swift

 

 

@objc func refreshMessageCenterBadge() {
  DispatchQueue.main.async {
  if self.window?.rootViewController is UITabBarController {
  let messageCenterTab: UITabBarItem = (self.window!.rootViewController! as! UITabBarController).tabBar.items![self.MessageCenterTab]
   
  if (UAirship.inbox().messageList.unreadCount > 0) {
  messageCenterTab.badgeValue = String(stringInterpolationSegment:UAirship.inbox().messageList.unreadCount)
  } else {
  messageCenterTab.badgeValue = nil
  }
  }
  }
  }

Please sign in to leave a comment.