根据苹果示例,我可以使用TWRequest轻松发送推文,
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountaccountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
// Request access from the user to access their Twitter account
[account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
{
// Did user allow us access?
if (granted == YES)
{
// Populate array with all available Twitter accounts
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
// Sanity check
if ([arrayOfAccounts count] > 0)
{
// Keep it simple, use the first account available
ACAccount *acct = [arrayOfAccounts objectAtIndex:0];
// Build a twitter …Run Code Online (Sandbox Code Playgroud) 在升级到swift 2.0并经历了一系列错误后,我最终得到了这个错误,我不知道如何解决:
init() 不可用:使用 init(domain:code:userInfo:)
这是代码:
override func objectsDidLoad(error: NSError?) {
self.actInd.startAnimating()
for var i = 0; i < (objects!.count); i++ {
let countObject = (objects?[i] as! PFObject)
print( (countObject.objectId)! )
let queryT = PFQuery(className:"Transactions")
queryT.whereKey("eventID", equalTo:(countObject.objectId)!)
print( queryT.countObjects() )
self.countedEvents.append(countEvents(objectId: (countObject.objectId)!, count: queryT.countObjects() ))
print( (countObject.objectId)! )
self.actInd.stopAnimating()
}
super.objectsDidLoad(NSError())
}
Run Code Online (Sandbox Code Playgroud)
此处出现错误 - super.objectsDidLoad(NSError())
谢谢,斯图尔特
我正在尝试使用filteredArrayUsingPredicate与从.plist文件中的数据构建的数组.不知怎的,它似乎永远不会过滤我的数组.
这就是我的数组的构建方式:
DrillDownAppAppDelegate *AppDelegate = (DrillDownAppAppDelegate *)[[UIApplication sharedApplication] delegate];
self.tableDataSource = [AppDelegate.data objectForKey:@"Rows"];
copyDataSource = [ tableDataSource mutableCopy];
Run Code Online (Sandbox Code Playgroud)
然后我的谓词是这样的,
NSString *searchFor = search.text;
[tableDataSource release];
tableDataSource = [copyDataSource mutableCopy];
if ([searchFor length] > 0) {
NSLog(@"array = %@",tableDataSource);
NSPredicate *pred = [NSPredicate predicateWithFormat:@"Self beginswith[c] %@",searchFor];
[tableDataSource filteredArrayUsingPredicate:pred];
}
Run Code Online (Sandbox Code Playgroud)