小编Sle*_*lee的帖子

在NSNotification中传递的访问对象?

我有一个发布NSDictionary的NSNotification:

 NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:
                                          anItemID, @"ItemID",
                                          [NSString stringWithFormat:@"%i",q], @"Quantity",
                                          [NSString stringWithFormat:@"%@",[NSDate date]], @"BackOrderDate",
                                          [NSString stringWithFormat:@"%@", [NSDate date]],@"ModifiedOn",
                                          nil];

                    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"InventoryUpdate" object:dict]];
Run Code Online (Sandbox Code Playgroud)

我如何订阅此并从此NSDictionary获取信息?

在我的viewDidLoad我有:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recieveInventoryUpdate:) name:@"InventoryUpdate" object:nil];
Run Code Online (Sandbox Code Playgroud)

和班上的方法:

- (void)recieveInventoryUpdate:(NSNotification *)notification {
    NSLog(@"%@ updated", [notification userInfo]);
}
Run Code Online (Sandbox Code Playgroud)

当然记录一个空值.

objective-c nsnotifications ios

23
推荐指数
2
解决办法
2万
查看次数

在Storyboard中将多个UIBarButtonItem添加到UINavigationItem?

在此输入图像描述

您可以轻松添加单个UIBarButton项目,如我在Storyboard中所示.但我想添加几个,似乎我不能使用故事板?

这很烦人,因为那时我失去了故事板的全部概述,而且它是Segue的.

是这样的吗?第一个项目使用故事板,所以我想我可能会遗漏一些东西.

iphone ipad ios5

22
推荐指数
1
解决办法
6914
查看次数

返回状态代码未经授权在WebAPI中自定义IActionFilter

我正在使用asp.net WebAPI,我需要创建一个自定义ActionFilter,它会快速检查请求URI的用户是否真的能够获取数据.

他们已被授权通过基本身份验证使用Web服务,并且他们的角色已通过自定义角色提供程序进行验证.

我需要做的最后一件事是检查他们是否有权使用URI中的参数查看他们请求的数据.

这是我的代码:

public class AccessActionFilter : FilterAttribute, IActionFilter
    {

        public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> ExecuteActionFilterAsync(HttpActionContext actionContext, System.Threading.CancellationToken cancellationToken, Func<System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>> continuation)
        {

            var result = //code to see if they have permission returns either 0 or 1

            if (result==0) {
               throw new ArgumentException("You do not have access to this resource");
            }
            return continuation();
        }
    } 
Run Code Online (Sandbox Code Playgroud)

目前我只是抛出一个不是我想要的错误,我宁愿回来,System.Net.HttpStatusCode.Unauthorized但我对我压倒的方法感到有点恼火,我完全不理解它.

我该如何回归这个价值?

action-filter asp.net-mvc-4 asp.net-web-api

22
推荐指数
2
解决办法
2万
查看次数

在iTunes连接中删除待处理的应用程序"新版本"

我在iTunes连接中启动了我的应用程序的新版本,我不想和/或不需要它 - 我该如何摆脱它?目前处于"等待上传"状态.

xcode itunesconnect

21
推荐指数
2
解决办法
1万
查看次数

使用Json.Net解析google map geocode json对对象的响应

我有一个满是地址的数据库,我需要得到lat和long,所以我想循环遍历它们并使用Google Geocode来更新我的数据库.我被困在如何解析JSOn结果以获得我需要的东西:

var address = "http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false";
var result = new System.Net.WebClient().DownloadString(address);
GoogleGeoCodeResponse test = JsonConvert.DeserializeObject<GoogleGeoCodeResponse>(result);
Run Code Online (Sandbox Code Playgroud)

我以为我可以简单地构建一个快速类并使用JSON.Net来反序列化结果,它有点工作但我想我在我的类结构上吹它:

public  class GoogleGeoCodeResponse {

    public string status { get; set; }
    public geometry geometry { get; set; }

}

public class geometry {
    public string location_type { get; set; }
    public location location { get; set; }
}

public class location {
    public string lat {get;set;}
    public string lng {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

以下是从Google返回的内容示例:

{
  "status": "OK",
  "results": [ {
    "types": [ "street_address" ],
    "formatted_address": "1600 …
Run Code Online (Sandbox Code Playgroud)

c# json google-maps

20
推荐指数
2
解决办法
3万
查看次数

项目文件包含ToolsVersion ="4.0",此版本的MSBuild不支持

我如何摆脱这个错误,我使用Visual Studio 2008,因为2010年不会打开我的一些VB项目.

visual-studio

19
推荐指数
1
解决办法
4万
查看次数

使用SQL Server 2008中另一个数据库中的值更新一个数据库中的记录?

我需要使用旧数据库中1列的数据更新我的新数据库.基本上基于匹配ItemID,我需要在新DB中使用旧DB中的值设置Description列.我可以看到当我进行连接时需要更新的内容,但我不确定如何正确处理此更新.

sql sql-server-2008

18
推荐指数
1
解决办法
3万
查看次数

在延迟不使用NSThread或sleep()之后执行方法 - 还有其他选择吗?

有没有办法在iOS4中使用除NSThread以外的其他东西延迟调用方法或使用sleep()阻止UI?

iphone objective-c ipad ios

17
推荐指数
2
解决办法
5999
查看次数

如何在Xcode中使用相同的共享代码创建多个应用程序?

我正在开发2个不同的应用程序,它们共享95%的相同代码和视图.使用Xcode最好的方法是什么?

iphone xcode ipad ios

17
推荐指数
1
解决办法
6208
查看次数

使用ld + json脚本和razor视图编译错误

我试图在我的网站上添加一些schema.org的东西,剃刀视图引擎给我带来麻烦.这是我想要添加到我的主要布局的内容:

  <script type="application/ld+json"> 
        {
        "@context": "http://schema.org",
        "@type": "Organization",
        "url": "http://www.example.com",
        "logo": "http://www.example.com/media.ashx/repzio-icon.png"
        }
    </script>
Run Code Online (Sandbox Code Playgroud)

@context是这里的问题,我该如何解决这个问题?

asp.net asp.net-mvc razor schema.org asp.net-mvc-5

17
推荐指数
1
解决办法
2342
查看次数