我想将lat lon转换为CLLocationCoordinate2D.
self.currentLocation = {.latitude = 0.0, .longitude = 0.0};
Run Code Online (Sandbox Code Playgroud)
这给了我错误"预期的表达".
我究竟做错了什么?
我的iCloud核心数据应用程序在iOS7上运行良好并准备启动.当我在iOS 8上测试时,我收到以下错误,并且在尝试将数据上传到iCloud时似乎无法修复它.
我怀疑我的问题与我如何获取文档目录以及iOS8中的doc目录中的更改有关,但我无法弄清楚这一点.
014-10-12 15:14:17.862 XXXXXXX [4662:236693] __45-[PFUbiquityFilePresenter processPendingURLs]_block_invoke(439): CoreData: Ubiquity: Librarian returned a serious error for starting downloads Error Domain=BRCloudDocsErrorDomain Code=6 "The operation couldn’t be completed. (BRCloudDocsErrorDomain error 6 - Path is outside of any CloudDocs container, will never sync)" UserInfo=0x7f8b1a525f60 {NSDescription=Path is outside of any CloudDocs container, will never sync, NSFilePath=/Users/garyrea/Library/Developer/CoreSimulator/Devices/9AADFE8E-5ECC-4969-9418-57DA45B747C9/data/Containers/Data/Application/AD2E5E62-7295-4371-A08D-1790E8FCCD96/Documents/CoreDataUbiquitySupport/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/5B8BFA36-1ACA-4966-B7ED-A7344D36ACF1/container/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/2trlqdMQVpJ~wlEfiLvjWtQfrUJ8YiNCd84KW_xiw4A=/F0CF5F29-D437-4728-B0A2-C5BB90BBC239.1.cdt} with userInfo {
NSDescription = "Path is outside of any CloudDocs container, will never sync";
NSFilePath = "/Users/garyrea/Library/Developer/CoreSimulator/Devices/9AADFE8E-5ECC-4969-9418-57DA45B747C9/data/Containers/Data/Application/AD2E5E62-7295-4371-A08D-1790E8FCCD96/Documents/CoreDataUbiquitySupport/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/5B8BFA36-1ACA-4966-B7ED-A7344D36ACF1/container/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/2trlqdMQVpJ~wlEfiLvjWtQfrUJ8YiNCd84KW_xiw4A=/F0CF5F29-D437-4728-B0A2-C5BB90BBC239.1.cdt";
} for these urls: (
"file:///Users/garyrea/Library/Developer/CoreSimulator/Devices/9AADFE8E-5ECC-4969-9418-57DA45B747C9/data/Containers/Data/Application/AD2E5E62-7295-4371-A08D-1790E8FCCD96/Documents/CoreDataUbiquitySupport/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/5B8BFA36-1ACA-4966-B7ED-A7344D36ACF1/container/nobody~simA28745A4-A67F-598C-9260-F9AC36609ECF/iCloud/2trlqdMQVpJ~wlEfiLvjWtQfrUJ8YiNCd84KW_xiw4A=/F0CF5F29-D437-4728-B0A2-C5BB90BBC239.1.cdt"
)
Run Code Online (Sandbox Code Playgroud)
我创建持久存储的应用程序委托扩展代码如下所示.我有第一次安装的种子数据库.
- …Run Code Online (Sandbox Code Playgroud) 我看到人们使用的两种变体......只是不知道浮动还不够iOS5?
在我的Xcode项目中,我有以下类:
地址
@interface LDAddress : NSObject{
NSString *street;
NSString *zip;
NSString *city;
float latitude;
float longitude;
}
@property (nonatomic, retain) NSString *street;
@property (nonatomic, retain) NSString *zip;
@property (nonatomic, retain) NSString *city;
@property (readwrite, assign, nonatomic) float latitude;
@property (readwrite, assign, nonatomic) float longitude;
@end
Run Code Online (Sandbox Code Playgroud)
地点
@interface LDLocation : NSObject{
int locationId;
NSString *name;
LDAddress *address;
}
@property (readwrite, assign, nonatomic) int locationId;
@property (nonatomic, retain) LDAddress *address;
@property (nonatomic, retain) NSString *name;
@end
Run Code Online (Sandbox Code Playgroud)
在UITableViewController的子类中,有一个NSArray包含许多LDLocations的未排序对象.现在,我想根据LDAddress 的属性城市对NSArray的对象进行升序排序.
如何使用NSSortDescriptor对数组进行排序?我尝试了以下方法,但在排序数组时应用程序转储.
NSSortDescriptor …Run Code Online (Sandbox Code Playgroud) 该项目在Simulator和设备上运行,但是当我尝试将其归档时,我收到了无意义的错误消息:
<command line>:2:10: Macro name missing
<command line>:3:9: Macro names must be identifiers
Run Code Online (Sandbox Code Playgroud)

PS我想补充更多细节,但是我完全不理解这可能是什么原因.
我试图在叠加中显示动画gif MKMapView.使用MKOverlayRenderer.创建叠加层.动画中的iOS 7的GIF,我使用的是UIImage+animatedGIF贴类别这里 GitHub上.
使用类别,动画gif的图像在叠加中显示得很好; 但是,gif没有动画.我没有问题使用类别来动画gif中的gif,UIImageView但它似乎无法在地图视图叠加中正常工作.
如何使用此类别将动画gif放置在地图视图叠加层中?
要么...
有没有办法UIImageView在覆盖中放置一个可以通过设置UIImageView动画gif 来解决我的问题?
我的叠加渲染器子类如下:
MapOverlayRenderer.h
#import <MapKit/MapKit.h>
@interface MapOverlayRenderer : MKOverlayRenderer
- (instancetype)initWithOverlay:(id<MKOverlay>)overlay overlayImage:(UIImage *)overlayImage;
@end
Run Code Online (Sandbox Code Playgroud)
MapOverlayRenderer.m
#import "MapOverlayRenderer.h"
@interface MapOverlayRenderer ()
@property (strong,nonatomic) UIImage *image;
@end
@implementation MapOverlayRenderer
- (instancetype)initWithOverlay:(id<MKOverlay>)overlay overlayImage:(UIImage *)overlayImage {
self = [super initWithOverlay:overlay];
if (self) {
_image = overlayImage;
}
return self;
}
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {
CGImageRef imageReference = self.image.CGImage;
MKMapRect theMapRect = [self.overlay …Run Code Online (Sandbox Code Playgroud) 我正在尝试为MKPolygon制作面积计算类别.我发现了一些JS代码https://github.com/mapbox/geojson-area/blob/master/index.js#L1一个链接的算法:http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409.它说:


这是我的代码,它给出了错误的结果(比实际数千倍):
#define kEarthRadius 6378137
@implementation MKPolygon (AreaCalculation)
- (double) area {
double area = 0;
NSArray *coords = [self coordinates];
if (coords.count > 2) {
CLLocationCoordinate2D p1, p2;
for (int i = 0; i < coords.count - 1; i++) {
p1 = [coords[i] MKCoordinateValue];
p2 = [coords[i + 1] MKCoordinateValue];
area += degreesToRadians(p2.longitude - p1.longitude) * (2 + sinf(degreesToRadians(p1.latitude)) + sinf(degreesToRadians(p2.latitude)));
}
area = area * kEarthRadius * kEarthRadius / 2;
}
return area;
} …Run Code Online (Sandbox Code Playgroud) 当我有一个图像时,我插入了CAGradientLayer的子图层,
...
layer.name = @"Gradient";
[cell.imageView.layer insertSublayer:layer atIndex:0];
Run Code Online (Sandbox Code Playgroud)
当ImageView没有图像时,我需要删除这个子图层.我尝试了不同的方法但没有成功.我试过的最后一次是
for (CALayer *layer in cell.imageView.layer.sublayers) {
if ([layer.name isEqualToString:@"Gradient"]) {
[layer removeFromSuperlayer];
}
}
Run Code Online (Sandbox Code Playgroud)
但它给了我一个错误:
CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. *** Collection <CALayerArray: 0xc1502e0> was mutated while being enumerated. with userInfo (null)
Run Code Online (Sandbox Code Playgroud) 我试过了:
- (IBAction)delete:(UIButton*)sender{
NSIndexPath *indexPath = [self.collectionView indexPathForCell:(TourGridCell *)[[[sender superview]superview]superview]];
}
Run Code Online (Sandbox Code Playgroud)
但NSLog显示单元格存在,但indexpath为零.
我有NSNumber * year属性NSManagedObject,它的数据模型类型是Integer 16.
我试着查看NSPredicate今年,但找不到合适的一个.
我尝试了什么:
NSPredicate *p = nil;
NSNumberFormatter *nf = [[NSNumberFormatter alloc] init];
NSNumber *yearNo = [nf numberFromString:term];
if (yearNo) {
p = [NSPredicate predicateWithFormat:@"(cars.year == %i)", yearNo.intValue];
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
NSPredicate *p = nil;
NSNumberFormatter *nf = [[NSNumberFormatter alloc] init];
NSNumber *yearNo = [nf numberFromString:term];
if (yearNo) {
p = [NSPredicate predicateWithFormat:@"(cars.year == %@)", yearNo];
}
Run Code Online (Sandbox Code Playgroud)
在这两种情况下应用程序崩溃.