Macos Mac应用程序UIImage和CGSize replacment
我有一个iOS类,可以从互联网上获取图像并对其进行操作。 我试图让它在MacOSX上工作,但在导入之后,我遇到了错误 我需要以下行的Mac等效项,例如UIImage=NSImageMacos Mac应用程序UIImage和CGSize replacment,macos,Macos,我有一个iOS类,可以从互联网上获取图像并对其进行操作。 我试图让它在MacOSX上工作,但在导入之后,我遇到了错误 我需要以下行的Mac等效项,例如UIImage=NSImage 1. NSImage *image = [NSImage imageWithData:[NSData dataWithContentsOfURL:imgurl]];(image with data) 2. NSValue *value=[NSValue valueWithCGSize:imgsize]; (v
1. NSImage *image = [NSImage imageWithData:[NSData dataWithContentsOfURL:imgurl]];(image with data)
2. NSValue *value=[NSValue valueWithCGSize:imgsize]; (value with size)
3. CGSize rect1 = [[obj1 valueForKey:@"size"] CGSizeValue];(cgsize value)
为什么不使用NSRect?NSRect相当于CGRect。 以下是解决方案:
1. NSImage *aImage = [[NSImage alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://..."]];
2. CGRect rc;
NSValue* rcValue = [NSValue valueWithRect:*(NSRect*)&rc];
3. NSRect rc1 = [rcValue rectValue];
CGRect rc2 = *(CGRect*)&rc1;
PS:CGRect到NSRect,方法是:NSRect nsrc=NSRect&cgrc