小编Har*_*ish的帖子

从核心数据和sqlite获取最大ID

我有一个表用户,并在核心数据模型中有一堆列.其中一列是user_id,我试图获得最高的user_id并向其添加+ 1并将其传递给将要插入的下一个对象.我按照苹果开发者指南进行了操作并按照建 这是我试图执行的代码.

问题是:我正在返回的account_id值被设置为某个奇怪的数字,甚至在数据库中也不存在.

"account_id"= 139784529; 它应该是1,因为我只保存在核心数据中.

NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Users" inManagedObjectContext:self._managedObjectContext];
[request setEntity:entity];

// Specify that the request should return dictionaries.
[request setResultType:NSDictionaryResultType];

// Create an expression for the key path.
NSExpression *keyPathExpression = [NSExpression expressionForKeyPath:@"account_id"];

// Create an expression to represent the function you want to apply
NSExpression *expression = [NSExpression expressionForFunction:@"max:"
                                                     arguments:@[keyPathExpression]];

// Create an expression description using the minExpression and returning a date.
NSExpressionDescription *expressionDescription = [[NSExpressionDescription …
Run Code Online (Sandbox Code Playgroud)

core-data max ios

5
推荐指数
1
解决办法
1147
查看次数

如何将字符串转换为整数或浮点型

我有一个文本字段,用户可以在其中输入数字,并且我希望能够根据用户输入将字符串转换为整数或浮点数。在Ruby中有一种简单的方法吗?

例如:

User Input: "123"  -> Output: 123
User Input: "123.99" -> Output: 123.99
Run Code Online (Sandbox Code Playgroud)

ruby

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

同步AFNetworking呼叫

我目前在我的一个iPhone应用程序中使用AFNetworking.这是一个非常方便的库来进行异步调用.但是,我在我的应用程序中遇到了需要从服务器获取数据以继续前进的情况.所以我想出了这种等待回复的方式.

    MyAFNetworkClient *httpClient = [MyAFNetworkClient sharedClient];

    NSURLRequest *request = [httpClient requestWithMethod:@"GET" path:path parameters:nil];

__block int status = 0;

AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {

    [[NSNotificationCenter defaultCenter] postNotificationName:@"notificationName" object:JSON];

} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){
    @throw error.userInfo;
    status = 2;
    NSLog(@"Error... Status Code 2");

}];
[httpClient enqueueHTTPRequestOperation:operation];
[httpClient.operationQueue waitUntilAllOperationsAreFinished];

while (status == 0)
{
    // run runloop so that async dispatch can be handled on main thread AFTER the operation has
    // …
Run Code Online (Sandbox Code Playgroud)

iphone synchronous afnetworking

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

Fiddler - asp.net web api自定义POST

我有一个Backbone.js应用程序,它正在调用我的一个WEB API自定义POST方法.这是我的自定义POST的代码

WebApiConfig.cs

config.Routes.MapHttpRoute
            (
                name: "UserAdministrationApi",
                routeTemplate: "api/{controller}/PostUserInfo/{EmployeeDTO}",
                defaults: new
                {
                    EmployeeDTO = RouteParameter.Optional,
                    controller = "UserAdministration",
                    action = "PostUserInfo",
                });
Run Code Online (Sandbox Code Playgroud)

调节器

        [HttpPost]
        [ActionName("PostUserInfo")]
        public HttpResponseMessage PostUserInfo(EmployeeDTO value)
        {
            // handling POST
        }
Run Code Online (Sandbox Code Playgroud)

EmployeeDTO

   public class EmployeeDTO
   {
    public bool masAccess { get; set; }
    public bool reportAccess { get; set; }
    public string name { get; set; }
    public string office { get; set; }
   }
Run Code Online (Sandbox Code Playgroud)

当我在使用Backbone.js代码测试它之前尝试在Fiddler中测试它时,我得到500内部错误.不确定是什么问题

// FIDDLER TEST

POST : http://localhost:56501/api/useradministration/PostUserInfo



Request Body

  {
     masAccess:"true"
     reportAccess:"false" …
Run Code Online (Sandbox Code Playgroud)

c# asp.net backbone.js asp.net-web-api

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

(null):"_ ACFacebookAppIdKey",引自:ERROR

我正在尝试按照 https://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk/文档获取访问令牌以代表用户访问Facebook服务.

添加后 - (void)sessionStateChanged:(FBSession*)会话状态:(FBSessionState)状态错误:(NSError*)错误

    - (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
    return [FBSession openActiveSessionWithReadPermissions:nil
                                          allowLoginUI:allowLoginUI
                                     completionHandler:^(FBSession *session,
                                                         FBSessionState state,
                                                         NSError *error) {
                                         [self sessionStateChanged:session
                                                             state:state
                                                             error:error];
                                     }];
    }
Run Code Online (Sandbox Code Playgroud)

我得到(null):"_ ACFacebookAppIdKey",引用自:ERROR,它们是其中的24个.我不确定到底发生了什么.

有人可以帮我解决这个问题吗?

谢谢

sdk facebook ios6

0
推荐指数
1
解决办法
2075
查看次数