什么是NSConcreteData,它在哪里定义? [英] What is NSConcreteData, and where is it defined?

查看:1787
本文介绍了什么是NSConcreteData,它在哪里定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码:

[[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:mapURL]]

返回NSConcreteData的实例,而不是NSData NSConcreteData代表什么,以及为什么返回它而不是NSData的实例?此外,这个类在哪里定义? XCode抱怨它没有被定义,但我不知道应该包括什么,以获得类。

returns an instance of NSConcreteData as opposed to NSData (which I expected!). What does NSConcreteData represent, exactly, and why is it being returned instead of an instance of NSData? Further, where is this class defined? XCode is complaining that it hasn't been defined, but I don't know what I should include in order to get the class.

任何帮助赞赏!

推荐答案

Foundation框架在某些区域使用类集群来为各种类提供一个通用接口。这意味着,当您使用 NSData API创建一个 NSData 对象时,实例化的实际类并返回不同于 NSData ,但是可以并且应该被处理并被您的代码称为 NSData 对象。

The Foundation framework uses class clusters in certain areas to provide a common interface to various classes. What this means is that, when you use an NSData API to create an NSData object, the actual class that is instantiated and returned is different from NSData, but can and should be treated and referred to as an NSData object by your code.

在一天结束时,简单的答案是:忽略 NSConcreteData 的存在, code> NSData 。

At the end of the day, the simple answer is: ignore the existence of NSConcreteData and treat it like NSData.

有关类集群的详细信息,请参阅Apple的可可基础指南

For more information on class clusters, please see the Class Clusters section of Apple's Cocoa Fundamentals Guide.

这篇关于什么是NSConcreteData,它在哪里定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆