我想创建一个离线模式,即当用户创建某些内容或更改它在某处保存时,然后当出现互联网连接时 – 这些请求将转到服务器.我怎样才能做到这一点?如何在NSUserDefaults中存储块?如何不丢失指向这些块的指针?
它可以是不同的控制器.请帮帮我.我为我糟糕的英语道歉.
我试图在NSUserDefaults中保存这些对象
typedef voID (^ExecutionBlock)(voID);@interface OfflineBlockObject : NSObject@property (nonatomic,copy) ExecutionBlock block;@property (nonatomic,strong) NSArray<NSMutableArray *> *operandsArray;@property (nonatomic,strong) NSArray *conditionsArray;@endOfflineBlockObject *blockObject = [[OfflineBlockObject alloc] init]; BOol first = [self.reservation.reservationID boolValue]; NSArray *conditions = @[@(first),@(self.shouldCallSetTagsForReservation)]; NSArray *operands = @[@[[self.reservation Json],self.reservation.reservationID ? : @0,self.selectedTags ? : @[]],@[[self.reservation Json],@(self.shouldForceApproved),self.selectedTags? : @[]]]; blockObject.conditionsArray = [conditions copy]; blockObject.operandsArray = [operands copy]; @weakify(blockObject); blockObject.block = [^{ @strongify(blockObject); if ([blockObject.conditionsArray[0] boolValue]) { ReservationsModel *m = [[ReservationsModel alloc] init]; [m editReservation:blockObject.operandsArray[0][0] success:^(ID responSEObject) { if ([blockObject.conditionsArray[1] boolValue]) { [m setReservationTags:blockObject.operandsArray[0][1] Tags:blockObject.operandsArray[0][2] success:nil failure:nil]; } } failure:nil]; } else { self.reservation.eventID = self.reservationEvent.eventInfoID; ReservationsModel *m = [[ReservationsModel alloc] init]; [m createReservation:blockObject.operandsArray[1][0] shouldForceApproved:[blockObject.operandsArray[1][1] boolValue] success:^(ID responSEObject) { Reservation *reservation = [Reservation reservationWithJson:responSEObject]; if (reservation.reservationID) { if ([blockObject.conditionsArray[1] boolValue]) { [m setReservationTags:reservation.reservationID Tags:blockObject.operandsArray[0][2] success:nil failure:nil]; } } } failure:nil]; } } copy]; [[OfflineQueueHelper sharedHelper] addTask:blockObject];
但我的块属性变为null 总结
以上是内存溢出为你收集整理的iOS:在脱机状态下创建http请求队列全部内容,希望文章能够帮你解决iOS:在脱机状态下创建http请求队列所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)