缺少方法声明的上下文 [英] Missing context for method declaration

查看:31
本文介绍了缺少方法声明的上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 delite 工作室.

appdeladte.m 中出现错误:

缺少方法声明的上下文

在这个代码:- (void)application:(UIApplication *)application

at this code: - (void)application:(UIApplication *)application

didReceiveRemoteNotification:(NSDictionary *)userInfo

didReceiveRemoteNotification:(NSDictionary *)userInfo

谁能帮帮我

//  AppDelegate.m

//

//  Copyright (c) 2015 Sherdle. All rights reserved.

//

#import "AppDelegate.h"

#import <GoogleMaps/GoogleMaps.h>

#import "Config.h"

#import "CommonBanner.h"

@implementation AppDelegate

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

{

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];


[self.window makeKeyAndVisible];

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];


[GMSServices provideAPIKey: MAPS_API_KEY];

Config * obje = [[Config  alloc]init];


//TODO we also do this elsewhere, perhaps a global declaration would be better

NSIndexPath *selectedIndexPath  = [NSIndexPath indexPathForRow:0 inSection:0];

NSArray *sectionArray = [obje config];

NSArray *item = [[sectionArray objectAtIndex: selectedIndexPath.section] objectAtIndex:(selectedIndexPath.row + 1)];

rearViewController = [[RearTableViewController alloc]initWithNibName:@"RearTableViewController" bundle:nil];


UIViewController *viewController = [[rearViewController selectItem:item] init];


frontNav = [[UINavigationController alloc]initWithRootViewController:viewController];


rearNav = [[UINavigationController alloc]initWithRootViewController:rearViewController];


revealController = [[SWRevealViewController alloc]initWithRearViewController:rearNav frontViewController:frontNav];



[[UINavigationBar appearance] setBarTintColor:APP_THEME_COLOR];


[[UINavigationBar appearance]setTintColor:[UIColor whiteColor]];


[[UINavigationBar appearance]setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, nil]];


[[UIApplication sharedApplication] registerForRemoteNotificationTypes:

(UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];



if (ADS_ON){

[CommonBanner regitserProvider:[CommonBannerProvideriAd class]

withPriority:CommonBannerPriorityLow

requestParams:nil];


if (![ADMOB_UNIT_ID isEqualToString: @""]){


[CommonBanner regitserProvider:[CommonBannerProviderGAd class]

withPriority:CommonBannerPriorityHigh

requestParams:@{keyAdUnitID    : ADMOB_UNIT_ID,

keyTestDevices : @[]}];

}

[CommonBanner startManaging];

}

if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {

[[UIApplication sharedApplication]

registerUserNotificationSettings:[UIUserNotificationSettings

settingsForTypes:(

UIUserNotificationTypeSound |

UIUserNotificationTypeAlert |

UIUserNotificationTypeBadge)

categories:nil]];

[[UIApplication sharedApplication] registerForRemoteNotifications];

}


else {

[[UIApplication sharedApplication]

registerForRemoteNotificationTypes:(

UIRemoteNotificationTypeBadge |

UIRemoteNotificationTypeSound |

UIRemoteNotificationTypeAlert)];

}

self.window.rootViewController = revealController;

return YES;

}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {

// Important note: If the user restores backup data to a new device or computer,

// or reinstalls the operating system, the device token changes.

self.restClient = [[DSRestClient alloc] init];

self.restClient.delegate = self;

[self.restClient registerWithUrl:@"http://myserver/pnfw/register/"

andToken:deviceToken];

//NSString *newToken = [deviceToken description];

//newToken = [newToken stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];

//newToken = [newToken stringByReplacingOccurrencesOfString:@" " withString:@""];


//NSLog(@"My token is: %@", newToken);

}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error

{

// Manage failure

self.restClient = [[DSRestClient alloc] initWithKey:@""

andSecret:@""];

//NSLog(@"Failed to get token, error: %@", error);

}

- (void)restClientRegistered:(DSRestClient *)client

{


}

- (void)restClient:(DSRestClient *)client registerFailedWithError:(NSError *)error

{

}

- (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 throttle down OpenGL ES frame rates. 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 inactive 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:.

}

@end

//@implementation AppDelegate () <DSRestClientDelegate>

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

//Receiving Push Notifications

//You can retrieve notification data with the following code in the AppDelegate:

- (void)application:(UIApplication *)application

didReceiveRemoteNotification:(NSDictionary *)userInfo

{


// This method is called if the app is running in the foreground, but also

// if the user press "show" on the notification AND the app is in the background



NSDictionary *aps = userInfo[@"aps"];

NSString *title = aps[@"alert"];

NSString *eventId = userInfo[@"id"];



if (application.applicationState == UIApplicationStateActive)

{

// If the application is foremost and visible when the system delivers the notification,

// no alert is shown, no icon is badged, and no sound is played. So we need to display a

// notification to the user when the app is actually running in the foreground


}

else

{


// App was just brought from background to foreground because the user tapped on the notification

}

//Subscribing


restClient.delegate = self;

[restClient linkWithUrl:@"http://myserver/pnfw/register/"

andEmail:email];

//Those delegate methods are called:

- (void)restClientLinked:(DSRestClient *)client

withEmail:(NSString *)email

andCustomParameters:(NSDictionary *)customParameters;

- (void)restClient:(DSRestClient *)client

linkFailedWithError:(NSError *)error;

//You can add any custom fields to subscribers using the hook pnfw_register_custom_parameters and use this method:

restClient.delegate = self;

[restClient linkWithUrl:@"http://myserver/pnfw/register/"

andEmail:email

andCustomParameters:@{@"key": value}];

//Unregistering

//This method allows client device to unregister itself from push notifications. If the last token associated with an anonymous user is removed, the user is also removed.

restClient.delegate = self;

[restClient unregisterWithUrl:@"http://myserver/pnfw/unregister/"];

//Those delegate methods are called:

- (void)restClientUnregistered:(DSRestClient *)client;

- (void)restClient:(DSRestClient *)client

unregisterFailedWithError:(NSError *)error;

//Retrieving Posts

NSDate *timestamp = nil;

restClient.delegate = self;

[restClient loadPostsWithUrl:@"http://myserver/pnfw/posts/"

andTimestamp:timestamp];

//Those delegate methods are called:

- (void)restClient:(DSRestClient *)client

loadedPosts:(PNPosts *)posts;

- (void)restClientPostsUnchanged:(DSRestClient *)client;

- (void)restClient:(DSRestClient *)client

loadPostsFailedWithError:(NSError *)error;

//Retrieving specific Post

//This method returns the details of the specified post.

restClient.delegate = self;

[restClient loadPostWithUrl:@"http://myserver/pnfw/posts/"

andIdentifier:identifier];

//Those delegate methods are called:

- (void)restClient:(DSRestClient *)client

loadedPost:(PNPost *)post;

- (void)restClientPostUnchanged:(DSRestClient *)client;

- (void)restClient:(DSRestClient *)client

loadPostFailedWithError:(NSError *)error;

//Retrieving Categories

//This method allows client device to retrieve the list of post categories.

NSDate *timestamp = nil;

restClient.delegate = self;

[restClient loadCategoriesWithUrl:@"http://myserver/pnfw/categories/"

andTimestamp:timestamp;

//Those delegate methods are called:

- (void)restClient:(DSRestClient *)client

loadedCategories:(PNCategories *)categories;


- (void)restClientCategoriesUnchanged:(DSRestClient *)client;


- (void)restClient:(DSRestClient *)client

loadCategoriesFailedWithError:(NSError *)error;


//Updating Categories

restClient.delegate = self;

[restClient updateCategoryWithUrl:@"http://Myserver/pnfw/categories/"

andIdentifier:identifier

andExclude:exclude;

//Those delegate methods are called:

- (void)restClientCategoryUpdated:(DSRestClient *)client;

- (void)restClient:(DSRestClient *)client

updateCategoryFailedWithError:(NSError *)error;


//Retrieving User Categories

NSDate *timestamp = nil;

restClient.delegate = self;

[restClient loadUserCategoriesWithUrl:@"http://myserver/pnfw/user-categories/"

andTimestamp:timestamp];

//Those delegate methods are called:

- (void)restClient:(DSRestClient *)client

loadedUserCategories:(PNUserCategories *)categories;


- (void)restClientUserCategoriesUnchanged:(DSRestClient *)client;



- (void)restClient:(DSRestClient *)client

loadUserCategoriesFailedWithError:(NSError *)error;


//Updating User Categories

restClient.delegate = self;

[restClient updateUserCategoryWithUrl:@"http://myserver/pnfw/user-categories/"

andIdentifier:identifier];

//Those delegate methods are called:


- (void)restClientUserCategoryUpdated:(DSRestClient *)client;


- (void)restClient:(DSRestClient *)client

updateUserCategoryFailedWithError:(NSError *)error;

推荐答案

你把方法放在 @end 之后,所以编译器不知道它属于哪个类.

You placed the method after the @end, so the compiler doesn't know what class it is part of.

这篇关于缺少方法声明的上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆