Giter VIP home page Giter VIP logo

Comments (5)

Danie1s avatar Danie1s commented on September 15, 2024

我明白你的需求了

实现后台下载的第一规则:TRManager必须在App启动时创建

而你这个需求的解决方法:
给AppDelegate添加一个可选属性manager,用户登录的时候,创建独自的manager,identifier跟用户关联,同时赋值给AppDelegate的属性,把identifier保存到沙盒的文件里

在didFinishLaunchingWithOptions方法读沙盒的文件,根据identifier创建manager,同时赋值给AppDelegate的属性,在handleEventsForBackgroundURLSession里就可以拿到对应的manager。

切换用户的时候,应该把当前用户的下载任务都暂停,然后销毁当前用户的manager,再创建新的manager

from tiercel.

lihanst avatar lihanst commented on September 15, 2024

我第一次创建 TRManager 并不是在 didFinishLaunchingWithOptions 方法里,然后并不会出现问题,问题出在我切换用户重新构建新的 TRManager 后再去进行下载的时候。

from tiercel.

Danie1s avatar Danie1s commented on September 15, 2024

请你按照我说的方法尝试一下

from tiercel.

lihanst avatar lihanst commented on September 15, 2024

必须要在 APP 启动时创建么?我需要根据用户来创建 Manager,但是此时用户还没有登录怎么办呢?我现在发现的问题是,第一次且不在 APP 启动时创建 Manager 并不会有问题,但是重复创建相同 identifier 的 Manager 再进行下载操作就会导致这个崩溃的出现。我试过在 app 启动时创建 manager,之后销毁再重新创建新的有相同 identifier 的 manager(即用户退出登录又重新登录),此时崩溃是必现的。但是创建不同 identifier 的 manager 没有问题(用户换了帐号登录)。

from tiercel.

Danie1s avatar Danie1s commented on September 15, 2024

呃。。。。你好像没理解我说的做法,你先跟着我说的做一边,再去理解这样做的意义。

同一个用户是同一个identifier,此时不销毁manager即可。

from tiercel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.