I have a really large loop in my program, and I use a lot of temporary and instance variables. As my loop keeps running, the program uses up more and more memory until it crashes. Can I get some advice on how to do correct memory management in this situation? My main question is, why is the following code wrong?
Here is the code that is...
The following code in my function (run in a loop) is causing my program to use more and more memory until it crashes. What am I doing wrong?
- (void) processTrackValues:(NSMutableArray*) tags {
NSImage* trackArt = [tags objectAtIndex:5];
NSMutableArray* tempArtArray = [[NSMutableArray alloc] init];
[tempArtArray addObj...
Hello all,
I have a simple method to read a string and parse it to an array,
-(NSArray *) readFileToArray: (NSString *)file{
NSString *values = [NSString stringWithContentsOfFile: file];
NSArray *tokens = [values componentsSeparatedByString:@":"];
return tokens;
}
however instruments did report me I got a leak on NSString at line...
In the following code example from the Core Data Programming Guide, NSFetchRequest is created
with autorelease while NSSortDescriptor is not created with autorelease. Why wasn't NSSortDescriptor created with autorelease? Is it a matter of preference?
NSManagedObjectContext *moc = [self managedObjectContext];
NSEntityDescription *e...
Hey all,
I'm working through the Beginning iPhone Develoopment book and for some reason the project we're working on refuses to launch in the simulator, I think I've narrowed it down to something in the datePickerViewController.xib but heck if I know what is wrong, if I disconnect the uidatepicker outlet from the file's owner it works ...
I want to record the sound of my iPhone-App. So like someone is playing something on a iPhone instrument and after that you can hear it.
Is it possible without the micro?
...
I was under the impression that with key-value coding, I could set any undefined attribute on a NSManagedObject at runtime and no exception would be thrown, but it wouldbe a way to hold objects attached to the model that are not in the data model.
For example, I have a Foo object that does not have a "bar" attribute. I though that at r...
I am getting the error
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
every time I try to run the program on the iPhone device and the Simulator.
I am also seeing this:
ld: duplicate symbol .objc_class_name_MainView in /Volumes/Mark's Flash Drive/iFtB/build/iFtB.build/Debug-i...
I have a UIView in a UIScrollView in a UIView in a .xib that contains several buttons. If I move that UIView down by several pixels from within viewWillAppear, the buttons all stop responding to taps.
Here's the code I'm using to resize the UIScrollView and shift the buttons down:
// adjust the view height to accomodate the resize...
How can I create a class with the initializer initWithObjects?
Or does it just make more sense to inherit from NSArray and work around it that way?
...
I currently have a loop which iterates through an NSArray of NSString objects. I would like an NSString variable to be created on each iteration of the loop, using the currently evaluated NSString object's string value (from the NSArray) as the name of the variable. This is probably best explained through example:
for (i = 0; i < [array...
Could someone please explain how to go about getting the values passed to a non-existant method that is being intercepted when using:
+ (void)forwardInvocation:(NSInvocation *)anInvocation;
+ (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector;
Given a message like:
[SomeClass doSomething:@"theThing" withSomething:@"aPar...
I am calling a function repeatedly with a loop, and the loop runs inside of a thread. The thread has an autorelease pool.
I have the following code inside that function:
NSXMLDocument* undoXML;
NSData* undoData = [NSData dataWithContentsOfFile:undoFilePath];
undoXML = [[NSXMLDocument alloc] initWithData:undoData opti...
How can I get the number of times an NSString (for example, @"cake") appears in a larger NSString (for example, @"Cheesecake, apple cake, and cherry pie")?
I need to do this on a lot of strings, so whatever method I use would need to be relatively fast.
Thanks!
...
I am using the UIWebView to load both streaming audio and video. I have properly set up the UIWebView delegate and I am receiving webViewDidStartLoading and webViewFinishedLoading events perfectly. The webview launches a full screen window (likely a MPMoviePlayerController)
Apple's MoviePlayer example gets the array of Windows to deter...
The following function is a method of a class called TitleOverlay - which is a transparent overlay with a textView.
The function shows the overlay by animating its alpha, and in parallel uses the animationWillStart property of the animation to show the keyboard.
On 3G phones, the first time this function is called, there is some lag be...
static NSInteger shakeCount=0;
static NSDate *shakeStart;
static NSOrderedDecending;
NSDate *now=[[NSDate alloc]init];
NSDate *checkDate=[[NSDate alloc] initWithTimeInterval:1.5f sinceDate:shakeStart];
if([now compare:checkDate]==NSOrderedDecending || shakeStart ==nil)
{
shakeCount=0;
[shakeStart release];
shakeStart=[[NSDat...
Hello All,
I'm struggling with a memory leak of sqlite3. I have the following line in my code
score.division = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectStmt, 9)];
and it works fine. But when i look at memory leak instrument, i noticed a memory leak so after struggling a bit, i noticed if this statement is not t...
Hi everybody,
Can anyone tell me how to save an image from my application to the Wallpaper's folder in iphone using Xcode. The image will be downloaded from the server and displayed on UIImageView.
Can anyone help me with this...
Any code will be very helpful...
Thanx in advance...
...
A... as I learn Objective C.
There will be close to 20 button on a view at a time... :)
If I use a if/else loop for each button touched, it works great but I consider that to be inelegant and just plain cumbersome.
SO, I am using the button.tag to allow me to assign a number to each button then evaluate each button based on the .ta...