2014-04-09 47 views
0

我是新手到iOS,我想獲得一個數組有Parse.com查詢工作的NSMutableArray到一個NSArray Parse.com

userIDS = [[NSMutableArray alloc] init]; 

// example array that is from a UITableView 

for(int i = 1; i <= 3; i++) { 
    [userIDS addObject:[NSString stringWithFormat:@"user%i", i]]; 
} 

// Place user1, user2, user3 etc into a format like below so I can query multiple users. 

NSArray *names = @[@"user1", 
        @"user2", 
        @"user3"]; 

[pushQuery whereKey:@"playerName" containedIn:names]; 

我已經試過這

[pushQuery whereKey:@"playerName" containedIn:userIDS]; 

但那不起作用。

編輯如下,查找「playerName」的user1,user2,user3這正是我想要的。

userIDS = [[NSMutableArray alloc] init]; 

// example array that is from a UITableView 

for(int i = 1; i <= 3; i++) { 
    [userIDS addObject:[NSString stringWithFormat:@"user%i", i]]; 
} 

[pushQuery whereKey:@"playerName" containedIn:userIDS]; 
+2

你能更具體嗎? 「不起作用」是什麼意思?發生了什麼,你期望發生什麼? –

+0

我在分析中並不知道這個主題,但他們通常在分析幫助論壇上非常有幫助。 – 68cherries

+0

我再次查看了我的代碼,發現無關的拼寫錯誤,請參閱編輯。 – Jason

回答

0

你的數組必須string值的這個工作。要麼您必須有PFObjects並創建一個數組,其objectId或查詢playerName列,爲此,您必須在NSArray中具有string此列的值。

例如,如果你沒有PFObjects但要知道你正在尋找的名字做:

NSArray *names = [[NSArray alloc] initWithObjects:@"PlayerOne", @"PlayerTwo", nil]; 

    PFQuery * query = [PFQuery queryWithClassName:@"YourClass"]; 
    [query whereKey:@"playerName" containedIn:names]; 
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { 
     // Your objects here 
    }]; 

希望它能幫助。