iOS: Swift post video to tweet

ios
swift
twitterkit

#1

When i try add data to composter always will be crash if dost not add video all work good

  if (Twitter.sharedInstance().sessionStore.hasLoggedInUsers()) {
            var datamp : Data = Data()
        do {
            let url = URL(fileURLWithPath: ServerManager.sharedManager.twitterVideoShare)
            
            try datamp.write(to: url, options: Data.WritingOptions.atomicWrite)
            let composer = TWTRComposerViewController.init(initialText: "test message", image: nil, videoData: datamp)
            present(composer, animated: true, completion: nil)
        } catch  { print(error) }
        
       
    } else {
        Twitter.sharedInstance().logIn { session, error in
            if session != nil {
                var datamp : Data = Data()
                
                do {
                     let url = URL(fileURLWithPath: ServerManager.sharedManager.twitterVideoShare)
            
            try datamp.write(to: url, options: Data.WritingOptions.atomicWrite)
                    
                    let composer = TWTRComposerViewController.init(initialText: "test message", image: nil, videoData: datamp)
                    
                    self.present(composer, animated: true, completion: nil)
                } catch  { print(error) }
            }
        }
    }