在我的应用程序中,由于此核心数据保存错误处理代码,我收到了一堆SIGABRT崩溃报告(来自特定用户):
NSError *error = nil;
if (![moc save:&error])
{
if(error)
{
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
Run Code Online (Sandbox Code Playgroud)
有没有比使用abort()终止进程更好的方法来处理核心数据保存错误?
我有一个带2个按钮的界面,它们都调用相同的界面,但信息不同.在传统的界面上我使用prepareForSegue,但我不知道WatchKit上的等价物是什么.
我正在尝试使用此代码获取JSON存在于我的xcode资源中的文件
-(void)readJsonFiles
{
NSString *str=[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"classes.json"];
NSLog(@"Path: %@", str);
NSData *fileData = [NSData dataWithContentsOfFile:str];
NSLog(@"Data: %@", fileData);
SBJsonParser *parser = [[SBJsonParser alloc] init] ;
NSDictionary *jsonObject = [parser objectWithData:fileData];
NSLog(@"%@", jsonObject);
}
Run Code Online (Sandbox Code Playgroud)
path返回文件路径的这个链接
/Users/astutesol/Library/Application Support/iPhone Simulator/6.0/Applications/A4E1145C-500C-4570-AF31-9E614FDEADE4/The Gym Factory.app/classes.json
Run Code Online (Sandbox Code Playgroud)
但是当我登录时fileData它会归还给我null.我不知道我在哪里做错了.
我已经实现了一个在后台运行的NSURLSession(因此即使应用程序被挂起,它也可以使用系统守护程序继续执行任务).问题是
-(void)URLSession:(NSURLSession *)session
dataTask:(NSURLSessionDataTask *)dataTask
didReceiveResponse:(NSURLResponse *)response
completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler
Run Code Online (Sandbox Code Playgroud)
永远不会被称为.我需要知道响应状态,以便我能正确处理上传失败.根据另一篇文章,一位Apple工程师告诉我,当session为backgroundSession时,不会调用此委托方法来阻止应用程序唤醒.关于如何解决这个问题的任何建议?在我的情况中调用的最后一个URLSession委托方法是:
-(void)URLSession:(NSURLSession *)session
dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data
Run Code Online (Sandbox Code Playgroud) 我已更新到OS X Yosemite.当运行任何与远程repo(pull,fetch等)有关的git命令时,终端一直在询问我的github用户名和密码(远程在github上).如果我从mac的github客户端执行这些操作,它不会要求凭据.
我的git配置文件很好.我的SSH密钥也很好.我试图从Github应用程序重新安装git命令行工具但没有成功.
有什么建议?
我安装了这些pod文件.
pod 'TwitterKit'
pod 'TwitterCore'
当我尝试导入文件i时.e #import <TwitterKit/TwitterKit.h>显示未找到错误.
为什么会有任何想法?什么出错或什么都有待补充?
在过去的48小时内,GMSReverseGeocoderGoogle地图上的iOS SDK(最新版本2.7)会返回在过去正常工作的纬度和经度区域中缺少地址的结果.一个例子是:
GMSAddress {
coordinate: (37.915000, 23.730000)
lines: Alimos, Greece
subLocality: Alimos
locality: South Athens
administrativeArea: Decentralized Administration of Attica
country: Greece
}
Run Code Online (Sandbox Code Playgroud)
Lines应该包含整个地址,但现在它只包含sublocality和country.问题是它可以正常工作几个小时,然后它返回到这种结果,它永远不会返回错误,所以我可以使用回退机制进行反向地理编码.(结果可以在像Lyft这样依赖谷歌地图iOS SDK进行反向地理编码的流行应用中看到).
有没有人找到解决方法来解决这个问题?在最新的更新中,地理编码器没有api更改.
PS.对于相同的纬度/经度,Google Maps Web Api和Android Api会返回优质结果.
我有两个视图控制器A和B.ViewControllerA上有一个UICollectionView.
如果我将ViewControllerB推送到ViewControllerA,那么在后台ViewControllerA的UICollectionView更新中,我想强制集合视图重绘并使其单元格出列,这样当我从ViewControllerB返回时ViewControllerA的数据是最新的和正确的.调用reloadData不会使集合视图重新绘制它的自身,如果它在后台,它将等到viewWillAppear触发后
[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes],这是调用数据源以使新单元格出列的方法.
无论如何强制或欺骗集合[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes]视图,以便在调用viewWillAppear之前调用新单元格?
我试图让自定义视图控制器转换工作,如果在查看ViewControllerB时ViewControllerA中的数据已更改,则看起来很奇怪.我想强制collectionView更新,所以当我调用CollectionView.visibileIndexPaths时,会返回正确的项目并且我的动画看起来是正确的.
细节视图控制器支持窥视模式。当我们以窥视模式显示详细控制器时,需要禁用详细控制器中的工具提示/教程。我们如何确定视图控制器是以窥视模式还是全屏模式显示?
我使用Swift创建了一个iOS应用程序.现在我有一个问题,我想让我的文本中心+底部在一个标签中,中心+顶部在另一个标签中.有可能吗?
我试过这个
//Here learnItem is my label.
let constraintSize: CGSize = CGSizeMake(learnItem.frame.size.width, CGFloat(MAXFLOAT))
let textRect: CGRect = learnItem.text!.boundingRectWithSize(constraintSize, options: .UsesLineFragmentOrigin, attributes: [NSFontAttributeName: learnItem.font], context: nil)
learnItem.drawRect(textRect);
Run Code Online (Sandbox Code Playgroud)
它不会影响任何事情.所以也许这是一个wromg代码.我也看到了
learnItem.textAlignment = .Center
Run Code Online (Sandbox Code Playgroud)
有选择权center, justified, left, natural, right.但这不是我想要的.
请有人帮助我如何使我的文本中心+底部和中心+顶部?
注册通知的代码是:
UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
Run Code Online (Sandbox Code Playgroud)
以及安排通知的代码:
UILocalNotification *notification = [[UILocalNotification alloc] init];
[self setNotificationTypesAllowed];
if (notification)
{
if (allowNotif)
{
notification.timeZone = [NSTimeZone defaultTimeZone];
if ( [statusString isEqualToString:@"daily"]) {
notification.fireDate = _timePick.date;
notification.repeatInterval = NSCalendarUnitDay;
}else if ( [statusString isEqualToString:@"weekly"]) {
notification.fireDate = _timePick.date;
notification.repeatInterval = NSCalendarUnitWeekOfYear;
}else if ( [statusString isEqualToString:@"fortnightly"]) {
notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:60*60*24*14];;
notification.repeatInterval = NSCalendarUnitMinute;
//notification.repeatInterval = NSCalendarUnitYear;
}else{
notification.repeatInterval = 0; …Run Code Online (Sandbox Code Playgroud) 我有一个占用太多空间的应用程序,我想减轻重量,所以我决定将所有图像放在一个zip文件中并将其安装在应用程序中,而不是将图像添加到项目中.有可能,还是有人有更好的主意?谢谢
我正在开发电影应用程序,并希望在iOS中的短信阅读回复消息我发送了一个消息到4888888短信.后来我收到了号码的答复.我问,我可以阅读或访问该消息.
ios ×12
objective-c ×6
iphone ×3
ios7 ×2
3dtouch ×1
cocoapods ×1
core-data ×1
git ×1
github ×1
google-maps ×1
ios9 ×1
nsdata ×1
nsurlsession ×1
osx-yosemite ×1
swift ×1
twitter ×1
twitterkit ×1
uikit ×1
uilabel ×1
uistoryboard ×1
watchkit ×1
xcode ×1
zip ×1