想知道有经验的人是否可以解释这一点.我见过......的例子
[view release];
view = nil;
Run Code Online (Sandbox Code Playgroud)
....在(void)dealloc里面.
有什么区别,哪一个比另一个更好?什么是最好的方法?
在进行retainCount测试时,我个人已经看到nil为我减少了3到0的计数,但是只发布从3减少到2.
我一直在使用NSMutableArray,并且通过使用从数组中检索对象没有任何问题objectAtIndex:int.而不是通过整数将对象拉出数组,这是通过用字符串搜索数组来获取索引位置的一种方法.
animalOptions = [[NSMutableArray alloc] init];
//Add items
[animalOptions addObject:@"Fish"];
[animalOptions addObject:@"Bear"];
[animalOptions addObject:@"Bird"];
[animalOptions addObject:@"Cow"];
[animalOptions addObject:@"Sheep"];
NSString * buttonTitle = [animalOptions objectAtIndex:1];
// RETURNS BEAR
int * objectIndex = [animalOptions object:@"Bear"];
// THIS IS WHAT I NEED HELP WITH, PULLING AN INDEX INTEGER WITH A STRING (ex: Bear)
Run Code Online (Sandbox Code Playgroud)
希望这是有道理的,并且有答案,我无法在线研究并通过谷歌或苹果的课程参考找到任何东西.
我希望能够在我的应用程序中使用iPhone Mail.app,这样我的用户就可以在不离开应用程序的情况下发送共享电子邮件.我知道3.0使这成为可能.
我通过ctrl单击我的框架文件夹 - >添加现有框架来正确添加框架.
将此添加到我希望Mail.app出现的viewcontroller的头文件中.
#import <MessageUI/MessageUI.h>
Run Code Online (Sandbox Code Playgroud)
我弹出一个UIAlert,在关闭时我调用下面的函数,我的代码中没有出现错误.我是否必须在Interface Builder中做一些额外的事情?错误消息是在下面
-(void)showEmailModalView {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self; // <- very important step if you want feedbacks on what the user did with your email sheet
NSString * emailSubject = [[NSString alloc] initWithFormat:@"iPhone Subject Test"];
[picker setSubject:emailSubject];
NSString * content = [[NSString alloc] initWithFormat:@"iPhone Email Content"];
// Fill out the email body text
NSString *pageLink = @"http://mugunthkumar.com/mygreatapp"; // replace it with yours
NSString *iTunesLink = @"http://link-to-mygreatapp"; // …Run Code Online (Sandbox Code Playgroud) email iphone frameworks uiviewcontroller mfmailcomposeviewcontroller
好吧,我有一个难以追踪内存泄漏的世界.运行此脚本时,我没有看到任何内存泄漏,但我的objectalloc正在攀爬.Instruments指向CGBitmapContextCreateImage> create_bitmap_data_provider> malloc,这占我的objectalloc的60%.
使用NSTimer多次调用此代码.
//GET IMAGE FROM RESOURCE DIR
NSString * fileLocation = [[NSBundle mainBundle] pathForResource:imgMain ofType:@"jpg"];
NSData * imageData = [NSData dataWithContentsOfFile:fileLocation];
UIImage * blurMe = [UIImage imageWithData:imageData];
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
UIImage * scaledImage = [blurMe _imageScaledToSize:CGSizeMake(blurMe.size.width / dblBlurLevel, blurMe.size.width / dblBlurLevel) interpolationQuality:3.0];
UIImage * labelImage = [scaledImage _imageScaledToSize:blurMe.size interpolationQuality:3.0];
UIImage * imageCopy = [[UIImage alloc] initWithCGImage:labelImage.CGImage];
[pool drain]; // deallocates scaledImage and labelImage
imgView.image = imageCopy;
[imageCopy release];
Run Code Online (Sandbox Code Playgroud)
下面是模糊功能.我相信objectalloc问题位于此处.也许我只需要一双新鲜的眼睛.如果有人能想到这一点会很棒.对不起它有点长......我会试着缩短它.
@implementation UIImage(Blur)
- (UIImage *)blurredCopy:(int)pixelRadius …Run Code Online (Sandbox Code Playgroud) 有没有人在你自己的应用程序中嵌入iPhone的电子邮件程序?
让我试着简化一下.Tap Tap Revenge让你"挑战一个朋友".当你选择这样做时,他们打开标准的iPhone电子邮件程序(如果他们模仿它,它看起来很好),在具有预先填充数据的应用程序中.您所要做的就是从联系人中选择一位朋友,然后按发送.你永远不会离开Tap Tap Revenge App.
任何想法如何做到这一点?
iphone ×4
email ×2
cgimage ×1
cocoa ×1
dealloc ×1
frameworks ×1
memory ×1
memory-leaks ×1
mfmailcomposeviewcontroller ×1
uiimage ×1