I am currently a new developer, and I came across this error; SIGABRT. I have tried developing many apps, and a lot of them get this error. I am developing a sound matching educational app for little kids where they use one picker view in Xcode to match an animal and their sound. My code is as follows:
ViewController.m
#define componentCount 2
#define animalComponent 0
#define soundComponent 1
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController
#synthesize lastAction;
#synthesize matchResult;
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSString *actionMessage;
NSString *matchMessage;
int selectedAnimal;
int selectedSound;
int matchedSound;
if (component==animalComponent) {
actionMessage=[[NSString alloc]
initWithFormat:#"You Selected The Animal Named '%#'!",
[animalNames objectAtIndex:row]];
} else {
actionMessage=[[NSString alloc]
initWithFormat:#"You Selected The Animal Sound '%#'!",
[animalSounds objectAtIndex:row]];
}
selectedAnimal=[pickerView selectedRowInComponent:animalComponent];
selectedSound=[pickerView selectedRowInComponent:soundComponent];
matchedSound=([animalSounds count] - 1) -
[pickerView selectedRowInComponent:soundComponent];
if (selectedAnimal==matchedSound) {
matchMessage=[[NSString alloc] initWithFormat:#"Yes, A '%#' Does Go '%#'!"];
[animalNames objectAtIndex:selectedAnimal],
[animalSounds objectAtIndex:selectedSound];
} else {
matchMessage=[[NSString alloc] initWithFormat:#"No, A '%#' Doesn't Go '%#'!"];
[animalNames objectAtIndex:selectedAnimal],
[animalSounds objectAtIndex:selectedSound];
}
lastAction.text=actionMessage;
matchResult.text=matchMessage;
[matchMessage release];
[actionMessage release];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (component==animalComponent) {
return [animalNames objectAtIndex:row];
} else {
return [animalSounds objectAtIndex:row];
}
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
if (component==animalComponent) {
return [animalNames count];
} else {
return [animalSounds count];
}
}
- (void)dealloc {
[animalNames release];
[animalSounds release];
[lastAction release];
[matchResult release];
[super dealloc];
}
- (void)viewDidLoad {
animalNames=[[NSArray alloc]initWithObjects:
#"Cat", #"Dog", #"Snake", #"Cow", #"Horse", #"Pig", #"Duck", #"Sheep", #"Bird",nil];
animalSounds=[[NSArray alloc]initWithObjects:
#"Chirp", #"Baa", #"Quack", #"Oink", #"Nay", #"Moo", #"Hiss", #"Bark", #"Purr",nil];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
#end
ViewController.h
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate> {
NSArray *animalNames;
NSArray *animalSounds;
IBOutlet UILabel *lastAction;
IBOutlet UILabel *matchResult;
}
#property (nonatomic, retain) UILabel *lastAction;
#property (nonatomic, retain) UILabel *matchResult;
#end
Where The SIGABRT Is
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
//at end of row of code above this, there was the error message: signal SIGABRT
}
}
Anyways, I absolutely need help on what I should do in order to get rid of this SIGABRT error. Thank you.
You have to identify the line of code that is causing the problem, something we cannot identify from the snippet of code.
You may want to enable exception breakpoints, as they often can identify the precise exact line of code that is causing the exception. When I encounter exceptions in my development, I'll simply add an exception breakpoint on "All" exceptions (see Breakpoint Navigator Help or the screen snapshot below). That way, if I'm running the program through my debugger, when it encounters an exception, it will stop the code at the offending line, greatly simplifying the process of identifying the source of the problem. It doesn't always work perfectly, but it frequently finds the source of the exception more quickly than other techniques.
For a broader discussion on debugging apps (e.g. using the debugger to single step through your code, see the Xcode User Guide: Debug your App. If you know the problem is in this method, you might want to step through your code, line by line, and the problem will become self-evident.
I'd also suggest you check out My App Crashed, Now What on the Ray Wenderlich site.
You seem to have some formatting issues with your match message:
matchMessage=[[NSString alloc] initWithFormat:#"Yes, A '%#' Does Go '%#'!"];
[animalNames objectAtIndex:selectedAnimal],
[animalSounds objectAtIndex:selectedSound];
I'm surprised the compiler will actually compile this, but anyhow - you need to include the selected strings within the method call stringWithFormat:
Try below:
matchMessage = [[NSString alloc] initWithFormat:#"Yes, A '%#' Does Go '%#'!",
[animalNames objectAtIndex:selectedAnimal],
[animalSounds objectAtIndex:selectedSound]
];
Your compiler will definitely be giving you a warning about this. So your first step should always be to fix the compiler warnings. It's good practice to turn on the 'Treat warnings as errors' option in build settings. This means that the compiler is very strict about what it will accept and run - which means that you have to fix the warnings. There's really no excuse for having warnings from your compiler.
Read the english before the first call stack. What does it tell you? The most common form of sigabrt is where an IBOutlet gets deleted in the .h file and the outlet connection is still there in the storyboard. To solve this, delete all outlet connections in the storyboard, rewrite the IBOutlets, and link them over again.
Related
I have made the basic build and it includes a picker. So whatever units of conversion the user selects from the picker, the labels should be updated to show the names of the units for that conversion and once the user enters the number in the text box and hits the button, the answer should be displayed in the second text box. Now the code executes, but the problem is no matter what I pick in the picker, it always does the weight conversion. I know I need a switch statement in there, but I'm not sure how or where I need to implement it.
Another problem is that the labels update, but only when the "Convert" button is pressed, so please help me fix this.
This is my ViewController.h file
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
<UIPickerViewDelegate, UIPickerViewDataSource> {
IBOutlet UITextField *field1;
IBOutlet UITextField *field2;
IBOutlet UIPickerView *picker;
IBOutlet UILabel *label1;
IBOutlet UILabel *label2;
}
#property (weak, nonatomic) IBOutlet UILabel *textLabelData1;
#property (weak, nonatomic) IBOutlet UILabel *textLabelData2;
#property (nonatomic, retain) UIPickerView *picker;
-(IBAction) currencyConvert:(id)sender;
-(IBAction) weightConvert:(id)sender;
-(IBAction) distanceConvert:(id)sender;
#end
This is my ViewController.m file
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController
#synthesize picker;
static NSString *pd[3] = {#"Currency", #"Weight", #"Speed"};
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark UIPickerViewDelegate & UIPickerViewDataSource methods
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
return 3;
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:
(NSInteger)row forComponent:(NSInteger)component;
{
return pd[row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:
(NSInteger)row inComponent:(NSInteger)component
{
NSLog(#"didSelectRow %li, inComponent: %li", row, component);
}
-(IBAction)currencyConvert:(id)sender
{
if (pd[0])
{
self.textLabelData1.text = #"Dollar";
self.textLabelData2.text = #"Rupees";
float dollar = [[field1 text] floatValue];
float rupees = dollar * 64.15;
[field2 setText: [NSString stringWithFormat: #"%3.3f", rupees]];
}
/* self.textLabelData1.text = #"Dollar";
self.textLabelData2.text = #"Rupees";
float dollar = [[field1 text] floatValue];
float rupees = dollar * 64.15;
[field2 setText: [NSString stringWithFormat: #"%3.3f", rupees]]; */
}
-(IBAction)weightConvert:(id)sender
{
if (pd[1])
{
self.textLabelData1.text = #"Kilogram";
self.textLabelData2.text = #"Lbs";
float kilogram = [[field1 text] floatValue];
float pounds = kilogram * 2.20462;
[field2 setText: [NSString stringWithFormat: #"%3.3f", pounds]];
}
}
-(IBAction)distanceConvert:(id)sender
{
if (pd[2])
{
self.textLabelData1.text = #"Mile";
self.textLabelData2.text = #"Kilometer";
float miles = [[field1 text] floatValue];
float kilometers = miles * 1.60934;
[field2 setText: [NSString stringWithFormat: #"%3.3f", kilometers]];
}
}
/* Pseudocode for switch statement
-- I tried doing this here, but it gives me an
error saying that "row" is undefined. I understand that
it is a local variable, but how else would I write the
switch statement?
Also, is the placement of the switch statement appropriate here
or will I need to implement it in a function?
switch (row)
{
case 1:
call currencyConvert
case2:
call weightConvert
case3:
call distanceConvert
}
*/
The link to the picture of my Main.storyboard
This isn't the ideal UI and creates inefficiencies, but its your app. I just wanted to point out that you might want to spend time working on its design and structure.
As for a solution to your problem, I cant fix everything for you, but I'll point out some things to make it easier for you.
The reason your labels are not updating is because you are not updating anything until you hit the convert button. The below function is where you'll get the event for the picker's new row
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:
(NSInteger)row inComponent:(NSInteger)component
{
NSLog(#"didSelectRow %li, inComponent: %li", row, component);
}
Try this instead:
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:
(NSInteger)row inComponent:(NSInteger)component
{
NSLog(#"didSelectRow %li, inComponent: %li", row, component);
switch (row) {
case 0:
self.textLabelData1.text = #"Dollar";
self.textLabelData2.text = #"Rupees";
break;
case 1:
// and so on
}
}
Your next issue is that you're not telling your "convert" functions what row is currently selected, and your conditional if does nothing.
In obj-c conditional statements used directly on a variable are basically just checks for initialization. if(x) simply means has x been initialized as a variable = true, if not = false. That's probably not the logic you're looking for in this case.
Next, It appears you're trying to link 3 different functions to the same button press? This is where your above if related issue is causing problems, all three functions are firing at the same time... but only one gets the last say. Presumably the one you linked last, though i cant say for sure. I'd suggest a single function that handles the button press and then relays to the correct methods.
Last, you're never telling the functions anything about the state of the picker. You need to set it as an IBOutlet so your variables will have access to it. Then you can use the picker's selected row function to determine which conversion to use.
The things I highlighted will fix your problems, BUT I would highly recommend checking out some tutorials so you'll learn more about why things do what. I'd recommend: https://www.raywenderlich.com/
Hope that helps!
I am testing a simple UIPickerView app so that I can use it as a class in my project...
the code works beautifully with ARC but as soon as I turn ARC off the build succeeds but crashes when I click on the display of the picker...the error displayed is "EXC_BAD_ACCESS(code=2, address=oxc)" at the line
return [pickerData1 objectAtIndex:row];
will be extremely grateful if someone can help...I have spent more than 7 working days [60hours+] trying all sorts of options given on the stackoverflow website but just can't get around the issue...needless to say I am trying to learn...
...i have learnt this much that there is a problem with the array...it is being released whereas it should be retained till the 'objectAtIndex' call...but I have tried countless ways of going about this none worked...its because i don't have an in-depth understanding of xcode as yet...trying to learn by doing...usually i am successful in figuring out how to apply sample code in my project and have successfully completed many complex parts of my project (it is an iPad app that deploys augmented reality technology), but am desperately stuck at this rather simple component...
this is the header file:
#import <UIKit/UIKit.h>
#interface PickerText : UIViewController<UIPickerViewDataSource, UIPickerViewDelegate>
{
NSArray *pickerData1;
}
#property (retain, nonatomic) IBOutlet UIPickerView *picker1;
#property (retain, nonatomic) IBOutlet UIButton *buttonForSelection1;
#end
and this is the implementation file
#import "PickerText.h"
#interface PickerText ()
//set tags to enable future incorporation of multiple pickers
#define kPICKER1COLUMN 1
#define kPICKER1TAG 21
#define kButton1Tag 31
#end
#implementation PickerText
#synthesize picker1;
#synthesize buttonForSelection1;
- (void)viewDidLoad
{
[super viewDidLoad];
// assign data in array
pickerData1 = #[#"[tap to select]", #"Item 1", #"Item 2", #"Item 3", #"Item 4", #"Item 5", #"Item 6"];
// Connect data
picker1.tag = kPICKER1TAG;
self.picker1.dataSource = self;
self.picker1.delegate = self;
picker1.hidden = YES;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
// set number of columns of data in picker view
- (int)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
if (pickerView.tag == kPICKER1TAG)
return kPICKER1COLUMN;
else { return 0; }
}
// The number of rows of data
- (int)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if (pickerView.tag == kPICKER1TAG)
return [pickerData1 count];
else { return 0; }
}
// The data to return for the row and component (column) that's being passed in (ie set the data in picker view)...
//method using NSString
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if (pickerView.tag == kPICKER1TAG)
return [pickerData1 objectAtIndex:row];
else { return 0; }
}
// Capture the picker view selection
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (pickerView.tag == kPICKER1TAG)
{
NSString *selection1 = [pickerData1 objectAtIndex:[picker1 selectedRowInComponent:0]];
//check selection
NSLog(#"%#", selection1);
//change display text on button
[buttonForSelection1 setTitle:selection1 forState:UIControlStateNormal];
[buttonForSelection1 setTitle:selection1 forState:UIControlStateSelected];
}
//to hide picker view after selection
pickerView.hidden=YES;
}
- (IBAction)showPicker:(id)sender
{
if ([sender tag] == kButton1Tag)
{
picker1.hidden = NO;
}
}
#end
many thanks in advance!!
And in case if you want to know what the issue is with ARC turned off. The Problem is here:(1)
#interface PickerText : UIViewController<UIPickerViewDataSource, UIPickerViewDelegate>
{
NSArray *pickerData1;
}
and here(2) -
pickerData1 = #[#"[tap to select]", #"Item 1", #"Item 2", #"Item 3", #"Item 4", #"Item 5", #"Item 6"];
You see, in ARC the default association is strong so when you write the second line, THE pickerData1 holds a strong reference to the autorelease array and it all works properly. But without ARC the default association is assign hence , since in line 2 you have assigned an autorelease array (which is getting released at some later point of time), you are getting the crash. You can learn the difference between assign and strong in the Apple documents.
Better you change the array to a strong property. Though without ARC, strong will simply mean retain.
Cheers, have fun.
Don't bother turning ARC off. You have the option to enable/disable ARC on a file-by-file basis:
-fobjc-arc to turn ARC on for a file in a project that doesn't work with ARC
-fno-objc-arc vice-versa
I am trying to make a calculator app, but when I press enter nothing is pushed into the array. I have a class called CaculatorBrain where the pushElement method is defined, however (for now) I defined and implemented pushElement method in the view controller.
When I log the operand object as it is typed in the console when enter is pressed the contents of array is nil! Why is that?
#import "CalculatorViewController.h"
#import "CalculatorBrain.h"
#interface CalculatorViewController ()
#property (nonatomic)BOOL userIntheMiddleOfEnteringText;
#property(nonatomic,copy) NSMutableArray* operandStack;
#end
#implementation CalculatorViewController
BOOL userIntheMiddleOfEnteringText;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(NSMutableArray*) operandStack {
if (_operandStack==nil) {
_operandStack=[[NSMutableArray alloc]init];
}
return _operandStack;
}
-(CalculatorBrain*)Brain
{
if (!_Brain) _Brain= [[CalculatorBrain alloc]init];
return _Brain;
}
- (IBAction)digitPressed:(UIButton*)sender {
if (self.userIntheMiddleOfEnteringText) {
NSString *digit= [sender currentTitle];
NSString *currentDisplayText=self.display.text;
NSString *newDisplayText= [currentDisplayText stringByAppendingString:digit];
self.display.text=newDisplayText;
NSLog(#"IAm in digitPressed method");
}
else
{
NSString *digit=[sender currentTitle];
self.display.text = digit;
self. userIntheMiddleOfEnteringText=YES;
}
}
-(void)pushElement:(double)operand {
NSNumber *operandObject=[NSNumber numberWithDouble:operand];
[_operandStack addObject:operandObject];
NSLog(#"operandObject is %#",operandObject);
NSLog(#"array contents is %#",_operandStack);
}
- (IBAction)enterPressed {
[self pushElement: [self.display.text doubleValue] ];
NSLog(#"the contents of array is %#",_operandStack);
userIntheMiddleOfEnteringText= NO;
}
It looks like the operand stack is never initialized.
When you directly access _operandStack you don't go through -(NSMutableArray*) operandStack, which is the only place where the operand stack is allocated and initialized. If the array isn't allocated you can't put anything in it, which is why it logs the contents as nil.
I'd recommend using either self.operandStack (which uses the method that checks if _operandStack is nil) everywhere except inside the -(NSMutableArray*) operandStack method, or allocating the operand stack in your viewDidLoad.
New to iOS and trying my best to get to grips with memory management and Instruments.
My problem is I'm getting weird memory losses when adding/removing a pickerview. I've set up a very basic example consisting of two buttons: one creates and shows the picker. The other one removes it from the main view.
Analyzer comes up clean and Instruments doesn't report any obvious leaks. BUT - heap memory continues to grow when I repeat this "show and hide" operation.
Here's the code. I'm on XCode 4.5, ARC enabled:
My ViewController.h:
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController <UIPickerViewDataSource,UIPickerViewDelegate>
#property (nonatomic,strong) UIPickerView *myPickerView;
- (IBAction)pickerButtonPressed:(id)sender;
- (IBAction)freeButtonPressed:(id)sender;
#end
ViewController.m:
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)pickerButtonPressed:(id)sender {
NSLog(#"Tap");
// create picker view on first button tap
UIPickerView* newPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(20, 20,160, 160)];
newPicker.dataSource = self;
newPicker.delegate = self;
newPicker.showsSelectionIndicator = YES;
self.myPickerView = newPicker;
[self.view addSubview:newPicker];
}
- (IBAction)freeButtonPressed:(id)sender {
NSLog(#"Free");
// remove from view and release
[self.myPickerView removeFromSuperview];
self.myPickerView = nil;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return 5;
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 2;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return #"Meh";
}
#end
Objects List on Instruments shows UIPickerView come and go nicely with every iteration, so it looks like it's being deallocated correctly. Well, not quite. This is a sample from the heapshot:
(sorry I'm not allowed to post images yet)
Now, if I'm actually releasing the pickerview correctly (removing from view and setting its reference to nil) where do those allocations come from?
On a side note - that UIPickerTableViewTitledCell thing on the stack trace strikes me as suspect because some people have had similar problems with leaking pickerviews involving that (see this one and this one), but I can't make head or tails of what I'm supposed to do with this. Not sure if they're actually related to my issue but with any luck they might point in the right direction.
Any tips?
For one of my last school projects, I am creating an iPad/iPhone application. For some days now I've been working on an issue with a certain memory leak. My application starts out on a specific view-controller (VCMainStatistics_iPad). From there, I push another view-controller (VCSocialMedia_iPad). Afterwards, I go back to the first view-controller.
When I repeat this sequence, I notice (by using Instruments - Activity Monitor) that the memory usage of the app keeps increasing. By disabling parts of the code, I eventually found out it has something to do with the pickerView. This code gives no leaks:
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return 0;
}
However, when I increase the number of rows, leaks start emerging (roughly 0.07 MB per row). Obviously, this is why I believe the pickerView is the cause of the leaks. I've been trying to remove the subviews from the pickerView before deallocation, setting pickerView to nil, and lots of other things... nothing fixes the issue. To hopefully make things a bit clearer, I'll post some more code.
The header file:
#import "UniversalViewController.h"
#define DATATYPE_SOCIALMEDIA 0
#interface VCSocialMedia_iPad : UniversalViewController <UIPickerViewDataSource, UIPickerViewDelegate>
{
NSArray *lMediaTypes;
NSMutableArray *lMediaData;
__weak IBOutlet UIPickerView *pkSocialMedia;
__weak IBOutlet UILabel *lblGraph;
}
#end
PickerView delegate methods:
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
// Get key of requested row
NSString *title = [[lMediaTypes objectAtIndex:row] capitalizedString];
// Capitalize first letter
title = [title capitalizedString];
// Return
return title;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
// Make or clear data lists
if( lGraphDayDataX[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] == nil ){
lGraphDayDataX[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] = [[NSMutableArray alloc] init];
}
else{
[lGraphDayDataX[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] removeAllObjects];
}
if( lGraphDayDataY[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] == nil ){
lGraphDayDataY[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] = [[NSMutableArray alloc] init];
}
else{
[lGraphDayDataY[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] removeAllObjects];
}
// Get required key
NSString *dictKey = [lMediaTypes objectAtIndex:row];
if( [dictKey isEqualToString:#"total_views"] ){
return;
}
// Adjust graph label
lblGraph.text = [NSString stringWithFormat:#"Stats from %#", dictKey];
// Get data of selected row
NSArray *mediaData = [lMediaData objectAtIndex:row];
// Add each day to data lists: inversed order
for( int day = [mediaData count]-1; day >= 0; day-- ){
NSDictionary *dayData = [mediaData objectAtIndex:day];
dictKey = #"wpsd_trends_date";
NSString *date = [dayData objectForKey:dictKey];
// Remove 00:00:00
date = [date stringByReplacingOccurrencesOfString:#" 00:00:00" withString:#""];
[lGraphDayDataX[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] addObject:date];
dictKey = #"wpsd_trends_stats";
NSString *stats = [dayData objectForKey:dictKey];
[lGraphDayDataY[iSelectedServerIndex][DATATYPE_SOCIALMEDIA] addObject:stats];
}
// Update the graphs
[self updateGlobalScreen];
}
PickerView datasource methods:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [lMediaTypes count];
}
Deallocation:
- (void)dealloc
{
pkSocialMedia = nil;
lblGraph = nil;
lMediaData = nil;
lMediaTypes = nil;
}
I only recently converted the project to Objective-C ARC, so there is a good chance this issue has something to do with my lack of experience with the concept. Apart from that, this is also my first Xcode project ever. Hopefully, someone here can help out: please let me know if I need to post more code to clarify things.
Thanks in advance!
Try removing the -(void)dealloc method. It shouldn't be implemented when you're using ARC. If you aren't using ARC, it needs to call [super dealloc].
Never found the solution itself, so I used a workaround: by replacing the NSPickerView with a NSTableView component, the leak did not occur anymore. For everyone who noticed the issue and tried to find a solution: thank you for trying!
I'm having a similar issue. It only happens when the UIPickerView is outside the bounds. The way I fixed it is to never have the UIPickerView move out of bounds (simply fade in and fade out to unhide/hide the UIPickerView). Probably a bug in UIKit.