0
你好,我有一個應用程序,可以計算你的互聯網連接的使用情況(讀取數據傳輸,漫遊數據,wifi ......)。我試圖用Widget更新它。該應用程序的第一部分,從數據庫中讀取值並在窗口小部件上顯示它們是完美的,但只有在主機應用程序處於打開狀態時纔會更新這些值。我希望小部件也能將數據保存到數據庫中,我已經閱讀了很多關於上下文衝突並試圖解決它的問題,但是對我來說沒有任何作用。在這裏,你有我的代碼:核心數據和今日小工具
TodayViewController.h
//
// TodayViewController.h
// WidgetCC
//
// Created by Óscar García Pérez on 25/3/15.
//
#import <UIKit/UIKit.h>
#import "Limits.h"
#import <CoreData/CoreData.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <net/if_dl.h>
#include "DataRegister.h"
#include "DataRegisterDetailDTO.h"
//#import "NewCalculateCostData.h"
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
#import <CoreLocation/CoreLocation.h>
#include "Alarms.h"
#include "User.h"
#import "SqliteSequence.h"
#import "NewDataRegister.h"
#import "CallRegister.h"
#import "LatestDataRegister.h"
@interface TodayViewController : UIViewController //<CLLocationManagerDelegate>
@property (readonly, strong, nonatomic) NSManagedObjectContext* managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel* managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator* persistentStoreCoordinator;
@property (nonatomic, retain) NSTimer* silenceTimer;
//@property (nonatomic, strong) CLLocationManager* locationManager;
@property (atomic) Boolean callActive;
@property (atomic) Boolean roamingStatus;
@property (nonatomic, strong) CLLocation* lastLocation;
@property (nonatomic, retain) NSString* currentMcc;
@property (nonatomic, retain) NSString* currentCountry;
@end
TodayViewController.m
[鏈接刪除]
幾乎所有這些方法都來自AppDelegate中:
AppDelegate.m
[鏈接被刪除]
在此先感謝。