English 中文(简体)
如何在OS找到任何物体的大小?
原标题:How to find the size of any object in iOS?

I was optimizing my app and wanted to know that how much is the size of the object, so that I can also show it in log.

附录一

NSDictionary *temp=(NSDictionary*)[Data objectAtIndex:i];

//data is defined in the .h file 

现在我会知道,物体的大小是多少?

我尝试采用不同的观点,在节节中,我发现:

instance_size=(long int)30498656

Is the instance_size the exact size of my temp object?.

我也曾尝试过审判。

sizeof(temp);

但它在这一点上坠毁。 任何帮助......

最佳回答

汇编者只了解点人,因此总是会回到点人的规模。 寻找被分配物体的大小,就象

NSLog(@"size of Object: %zd", malloc_size(myObject));
问题回答

我建议使用<条码>格_getInstanceSize和<条码>小型_good_size,以了解其间隔时间。 这不会显示原封不动,也不会出现在返回的面积之内。

#import <malloc/malloc.h>
#import <objc/runtime.h>

NSLog(@"Object Size: %zd", malloc_good_size(class_getInstanceSize([yourObject class])));

Variable temp is a memory address. We can not get the object memory size by programming. We can use the Allocations instrument to optimize app in xcode. Click Command+I in xcode4, you can find it.

In objective- C:

NSString *sampleString = @"iOS Programming";
 NSLog(@"size of object: %zd", malloc_size((__bridge const void *)(sampleString)));

You need to include:
#import<malloc/malloc.h>

In Swift:

var name: String = "Hello World!"

sizeofValue(name)

var someValue: Double = 10.5

sizeofValue(someValue)




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签