傳值

//

//? AppDelegate.h

//? test two

//

//? Created by 劉皇帝 on 2018/12/10.

//? Copyright ? 2018 劉皇帝. All rights reserved.

//

#import

#import

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property(readonly,strong)NSPersistentContainer*persistentContainer;

- (void)saveContext;

@end



//

//? AppDelegate.m

//? test two

//

//? Created by 劉皇帝 on 2018/12/10.

//? Copyright ? 2018 劉皇帝. All rights reserved.

//

#import "AppDelegate.h"

#import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {

? ? self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];

? ? return YES;

}

- (void)applicationWillResignActive:(UIApplication*)application {

? ? // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

? ? // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.

}

- (void)applicationDidEnterBackground:(UIApplication*)application {

? ? // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.

? ? // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

}

- (void)applicationWillEnterForeground:(UIApplication*)application {

? ? // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.

}

- (void)applicationDidBecomeActive:(UIApplication*)application {

? ? // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

}

- (void)applicationWillTerminate:(UIApplication*)application {

? ? // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

? ? // Saves changes in the application's managed object context before the application terminates.

? ? [self saveContext];

}

#pragma mark - Core Data stack

@synthesizepersistentContainer =_persistentContainer;

- (NSPersistentContainer*)persistentContainer {

? ? // The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.

? ? @synchronized (self) {

? ? ? ? if (_persistentContainer == nil) {

? ? ? ? ? ? _persistentContainer= [[NSPersistentContaineralloc]initWithName:@"test_two"];

? ? ? ? ? ? [_persistentContainerloadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription*storeDescription,NSError*error) {

? ? ? ? ? ? ? ? if(error !=nil) {

? ? ? ? ? ? ? ? ? ? // Replace this implementation with code to handle the error appropriately.

? ? ? ? ? ? ? ? ? ? // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.


? ? ? ? ? ? ? ? ? ? /*

?? ? ? ? ? ? ? ? ? ? Typical reasons for an error here include:

?? ? ? ? ? ? ? ? ? ? * The parent directory does not exist, cannot be created, or disallows writing.

?? ? ? ? ? ? ? ? ? ? * The persistent store is not accessible, due to permissions or data protection when the device is locked.

?? ? ? ? ? ? ? ? ? ? * The device is out of space.

?? ? ? ? ? ? ? ? ? ? * The store could not be migrated to the current model version.

?? ? ? ? ? ? ? ? ? ? Check the error message to determine what the actual problem was.

? ? ? ? ? ? ? ? ? ? */

? ? ? ? ? ? ? ? ? ? NSLog(@"Unresolved error %@, %@", error, error.userInfo);

? ? ? ? ? ? ? ? ? ? abort();

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }];

? ? ? ? }

? ? }


? ? return _persistentContainer;

}

#pragma mark - Core Data Saving support

- (void)saveContext {

? ? NSManagedObjectContext *context = self.persistentContainer.viewContext;

? ? NSError*error =nil;

? ? if([contexthasChanges] && ![contextsave:&error]) {

? ? ? ? // Replace this implementation with code to handle the error appropriately.

? ? ? ? // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.

? ? ? ? NSLog(@"Unresolved error %@, %@", error, error.userInfo);

? ? ? ? abort();

? ? }

}

@end




//

//? ViewController.h

//? test two

//

//? Created by 劉皇帝 on 2018/12/10.

//? Copyright ? 2018 劉皇帝. All rights reserved.

//

#import

@interfaceViewController :UIViewController

@end





//

//? ViewController.m

//? test two

//

//? Created by 劉皇帝 on 2018/12/10.

//? Copyright ? 2018 劉皇帝. All rights reserved.

//

#import "ViewController.h"

#import "SecondViewController.h"

#import

#import

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

? ? [super viewDidLoad];

? ? //導(dǎo)航條

? ? self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"附近違章高發(fā)地" style:UIBarButtonItemStyleDone target:self action:@selector(Cilck)];


? ? [AMapServices sharedServices].enableHTTPS = YES;


? ? ///初始化地圖

? ? MAMapView*_mapView = [[MAMapViewalloc]initWithFrame:self.view.bounds];


? ? ///把地圖添加至view

? ? MAUserLocationRepresentation *r = [[MAUserLocationRepresentation alloc] init];

? ? r.showsAccuracyRing = NO;///精度圈是否顯示,默認(rèn)YES

? ? r.showsHeadingIndicator = NO;///是否顯示方向指示(MAUserTrackingModeFollowWithHeading模式開啟)。默認(rèn)為YES

? ? r.strokeColor = [UIColor blueColor];///精度圈 邊線顏色, 默認(rèn) kAccuracyCircleDefaultColor

? ? r.lineWidth = 2;///精度圈 邊線寬度铺浇,默認(rèn)0

? ? //? ? r.locationDotBgColor = [UIColor greenColor];///定位點背景色籽御,不設(shè)置默認(rèn)白色

? ? r.fillColor= [UIColorredColor];

? ? r.strokeColor= [UIColorblackColor];

? ? [_mapViewupdateUserLocationRepresentation:r];

? ? _mapView.showsUserLocation = YES;

? ? _mapView.userTrackingMode = MAUserTrackingModeFollow;

? ? [self.viewaddSubview:_mapView];

? ? [AMapServices sharedServices].enableHTTPS = YES;



}

-(void)Cilck{

? ? //跳轉(zhuǎn)到違章的頁面

? ? SecondViewController *sec = [[SecondViewController alloc] init];

? ? [self.navigationController pushViewController:sec animated:YES];


}

@end




//

//? SecondViewController.h

//? test two

//

//? Created by 劉皇帝 on 2018/12/10.

//? Copyright ? 2018 劉皇帝. All rights reserved.

//

#import

NS_ASSUME_NONNULL_BEGIN

@interfaceSecondViewController :UIViewController

@end

NS_ASSUME_NONNULL_END





//

//? SecondViewController.m

//? test two

//

//? Created by 劉皇帝 on 2018/12/10.

//? Copyright ? 2018 劉皇帝. All rights reserved.

//

#import "SecondViewController.h"

#import "AFNetworking.h"

#import "PostViewController.h"

@interface SecondViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView *table;

@property(nonatomic,strong) NSMutableArray *dataScour;

@end

@implementationSecondViewController

- (void)viewDidLoad {

? ? [super viewDidLoad];

? ? //設(shè)置頭視圖

? ? self.title=@"查看違章";

? ? _table = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];

? ? _table.delegate=self;

? ? _table.dataSource = self;


? ? [self.view addSubview:_table];

? ? _dataScour = [[NSMutableArray alloc] init];

? ? _dataScour = @[@"平泉路中監(jiān)控抓拍",@"平泉路公交入口1閉路監(jiān)控抓拍"];

? ? NSDictionary*params =? @{@"lat":@"經(jīng)度",@"lon":@"緯度",@"key":@"6d96ee265cc090b418ee51257ff9c48f",@"page":@"dwad",@"pagesize":@"",@"r":@""};

? ? [self postDateUrl:@"http://v.juhe.cn/wzpoints/query" body:params

?? ? ];

}

- (void)postDateUrl:(NSString*)url body:(NSDictionary*)body

{

? ? [PostViewControllergetDataWithString:urlbody:bodyblock:^(idblock) {

? ? ? ? //block 是請求回得數(shù)據(jù)



? ? }];

}

-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{

? ? return _dataScour.count;

}

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{

? ? UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];


? ? cell.textLabel.text=_dataScour[indexPath.row];

? ? returncell;

}

@end





//

//? PostViewController.h

//?

//

//? Created by 劉皇帝 on 2018/12/10.

//

#import

#import "AFNetworking.h"

NS_ASSUME_NONNULL_BEGIN

typedefvoid(^AFNData)(idblock);

@interfacePostViewController :UIViewController

+(void)getDataWithString:(NSString*)string body:(NSDictionary*)parameters block:(AFNData)block;

@end

NS_ASSUME_NONNULL_END





//

//? PostViewController.m

//?

//

//? Created by 劉皇帝 on 2018/12/10.

//

#import "PostViewController.h"

#import "AFNetworking.h"

@interface PostViewController ()

@end

@implementationPostViewController

- (void)viewDidLoad {

? ? [super viewDidLoad];

? ? AFHTTPSessionManager *manger = [AFHTTPSessionManager manager];

? ? NSDictionary *dic = @{@"lat":@"string"};

? ? [mangerPOST:@"http://v.juhe.cn/wzpoints/query"parameters:dicsuccess:^(NSURLSessionDataTask*_Nonnulltask,id? _NullableresponseObject) {

? ? ? ? NSLog(@"%@",responseObject);

? ? }failure:^(NSURLSessionDataTask*_Nullabletask,NSError*_Nonnullerror) {


? ? }];

}

+ (void)getDataWithString:(NSString*)string body:(NSDictionary*)parameters block:(AFNData)block

{

? ? AFNetworkReachabilityManager *netWorkManager = [AFNetworkReachabilityManager sharedManager];


? ? NSString*url_string = [NSStringstringWithFormat:@"%@",string];

? ? url_string = [url_stringstringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];


? ? AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];


? ? manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];

//? ? NSDictionary *params =? [NSDictionary dictionaryWithObjectsAndKeys:@"參數(shù)1",@"lat",@"參數(shù)2",@"lon",@"參數(shù)3",@"key", nil];

? ? [managerPOST:url_stringparameters:parameterssuccess:^(NSURLSessionTask*task,idresponseObject)? {


//? ? ? ? [netWorkManager stopMonitoring];

? ? ? ? NSLog(@"%@",responseObject);

? ? ? ? block(responseObject);


? ? }failure:^(NSURLSessionTask*operation,NSError*error) {


? ? ? ? NSLog(@"失敗 === %@",error);

? ? ? ? dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{


? ? ? ? ? ? NSLog(@"Error: %@", error);

? ? ? ? });

? ? }];

}

/*

#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

? ? // Get the new view controller using [segue destinationViewController].

? ? // Pass the selected object to the new view controller.

}

*/

@end

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖窖式,帶你破解...
    沈念sama閱讀 222,627評論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異动壤,居然都是意外死亡萝喘,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,180評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來阁簸,“玉大人爬早,你說我怎么就攤上這事∑裘茫” “怎么了筛严?”我有些...
    開封第一講書人閱讀 169,346評論 0 362
  • 文/不壞的土叔 我叫張陵,是天一觀的道長饶米。 經(jīng)常有香客問我桨啃,道長,這世上最難降的妖魔是什么檬输? 我笑而不...
    開封第一講書人閱讀 60,097評論 1 300
  • 正文 為了忘掉前任照瘾,我火速辦了婚禮,結(jié)果婚禮上丧慈,老公的妹妹穿的比我還像新娘析命。我一直安慰自己,他們只是感情好逃默,可當(dāng)我...
    茶點故事閱讀 69,100評論 6 398
  • 文/花漫 我一把揭開白布鹃愤。 她就那樣靜靜地躺著,像睡著了一般完域。 火紅的嫁衣襯著肌膚如雪软吐。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,696評論 1 312
  • 那天筒主,我揣著相機與錄音关噪,去河邊找鬼鸟蟹。 笑死乌妙,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的建钥。 我是一名探鬼主播藤韵,決...
    沈念sama閱讀 41,165評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼熊经!你這毒婦竟也來了泽艘?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 40,108評論 0 277
  • 序言:老撾萬榮一對情侶失蹤镐依,失蹤者是張志新(化名)和其女友劉穎匹涮,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體槐壳,經(jīng)...
    沈念sama閱讀 46,646評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡然低,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,709評論 3 342
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片雳攘。...
    茶點故事閱讀 40,861評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡带兜,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出吨灭,到底是詐尸還是另有隱情刚照,我是刑警寧澤,帶...
    沈念sama閱讀 36,527評論 5 351
  • 正文 年R本政府宣布喧兄,位于F島的核電站无畔,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏吠冤。R本人自食惡果不足惜檩互,卻給世界環(huán)境...
    茶點故事閱讀 42,196評論 3 336
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望咨演。 院中可真熱鬧闸昨,春花似錦、人聲如沸薄风。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,698評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽遭赂。三九已至循诉,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間撇他,已是汗流浹背茄猫。 一陣腳步聲響...
    開封第一講書人閱讀 33,804評論 1 274
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留困肩,地道東北人划纽。 一個月前我還...
    沈念sama閱讀 49,287評論 3 379
  • 正文 我出身青樓,卻偏偏與公主長得像锌畸,于是被迫代替她去往敵國和親勇劣。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,860評論 2 361

推薦閱讀更多精彩內(nèi)容