Hi,
In a very small number of cases in my iphone app, I get a crash after the for loop in the code below:
ABAddressBookRef addressBookInit = ABAddressBookCreate();
CFMutableArrayRef abContacts =
(CFMutableArrayRef)ABAddressBookCopyArrayOfAllPeople(addressBookInit); // get array of all contacts
CFArraySortValues (abContacts, CFRangeMake(0, CFArrayGetCount(abContacts)), (CFComparatorFunction)ABPersonComparePeopleByName, (void *)ABPersonGetSortOrdering());
NSArray *copypeople = (NSArray *) abContacts;
NSMutableArray *tempTheadlist = [[NSMutableArray alloc] init];
for (int i=0; i < copypeople.count; i++)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ABRecordRef record = [copypeople objectAtIndex:i];
if (blah blah)
[tempThreadList addObject: someObject];
[pool release];
}
// POINT OF CRASH AFTER LOOP ENDS
if (tempTheadlist.count > 0)
[NSThread detachNewThreadSelector: @selector(loading_pictures:) toTarget:self withObject:tempTheadlist];
[tempTheadlist release];
[copypeople release];
CFRelease(addressBookInit);
Any reason why it should crash at any point here?
I have a UIImageView that is displaying a series of pictures as an animation. This part of the project works well.
I want to display a label when the animation ends. Is there an event that the Imageview will trigger when it's animation ends?
A view with a table gets pushed onto the screen and I want it to scroll to a certain row in the table before the screen actually displays. I use this code within the final viewcontroller.
NSIndexPath *scrollToPath = [NSIndexPath indexPathForRow:5 inSection:0];
[theTable scrollToRowAtIndexPath:scrollToPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
When I put it in viewDiDAppear method, then it briefly flashes from the intial position of the table (at the top) to the row I want. I don't want it to show the initial position. If I put it in viewDidLoad or viewWillAppear then it crashes with a NSRangeException, presumably because the table isn't set up yet.
How would I get it to scroll without showing the initial position?
I am trying to create a UIImageView called theImageView in the touchesBegan method that I can then then move to a new location in touchesMoved. Currently I am receiving an "undeclared" error in touchesMoved where I set the new location for theImageView.
What can I do to keep theImageView in memory between these two methods?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
...
UIImageView *theImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
theImageView.frame = CGRectMake(263, 228, 193, 300);
[theImageView retain];
...
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
...
theImageView.frame = CGRectMake(300, 300, 193, 300);
...
}
Say I have my class
@interface Person : NSObject { NSString *name; }
I need to get the name of NSString's within my class
Person *person = [[Person alloc] init];
NSLog(@"Name of variable %s\n", NameofVariable(person.name));
Hey,
I want to converte a CGRect "aRect" of a object in a subview in UITableViewCell in UITable to CGRect with respect to self.view.
The problem is that aRect is with respect to the subview in the table cell.
But i want to make it so that it is with respect to self.view
What i tried is this
rect = [self.view convertRect:aRect.frame toView:cellView];
but it doesn't work.
So how to convert it?
NSString* str = [[NSString alloc] initWithString:@"0.05"];
NSDecimalNumber* num = [[NSDecimalNumber alloc] initWithString:str];
NSLog(@" %@", num);
[str release];
[num release];
leaks memory
*** __NSAutoreleaseNoPool(): Object 0x707990 of class NSCFString autoreleased with no pool in place - just leaking
Can someone suggest a workaround ?
Newbie question about design patterns in objC.
I'm writing a functionality for my iphone app which I plan to use in other apps too. The functionality is written over two classes - Viewcontroller1 and Viewcontroller2. Viewcontroller1 is the root view of a navigation controller and it can push Viewcontroller2. Rest of the app will use only ViewController1 and will never access Viewcontroller2 directly. However, triggered
by user events, Viewcontroller2 has to send a message to the
rest of the app.
My question is what is the best way of achieving it?
Currently, I use two level of delegation to send the message out from Viewcontroller2. First send it to Viewcontroller1 and then let Viewcontroller1 send it to rest of the app or the application delegate. So my code looks like -
//Viewcontroller1.h
@protocol bellDelegate
-(int)bellRang:(int)size;
@end
@interface Viewcontroller1 : UITableViewController <dummydelegate> {
id <bellDelegate> delegate;
@end
//Viewcontroller1.m
@implementation Viewcontroller1
-(void)viewDidLoad {
//some stuff here
Viewcontroller2 *vc2 = [[Viewcontroller2 alloc] init];
vc2.delegate = self;
[self.navigationController pushViewController:vc2
animated:YES];
}
-(int)dummyBell:(int)size {
return([self.delegate bellRang:size]);
}
//Viewcontroller2.h
@protocol dummyDelegate
-(int)dummyBell:(int)size;
@end
@interface Viewcontroller2 : UITableViewController {
id <dummyDelegate> delegate;
@end
//Viewcontroller2.m
@implementation Viewcontroller2
-(int)eventFoo:(int)size {
rval = [self.delegate dummyBell:size];
}
@end
Which is the quickest way to view the value of a NSCFString variable in debugger window?
As for NSString, the string value is automatically displayed in the window or you move your mouse over it. But for a NSCFString, I tried same but cannot find the internal string.
I am trying to close a UIView thats in one method from another method by calling it, The UIView closes fine but not untill after all of the processes are finished in the current method.
I would like to know if there is a way to force the first thing to happen first (i.e. close UIviews) then continue the current method?
This is what my method looks like
- (void)selectDeselectAllPressed:(UIButton*)button {
int id = button.tag;
[SVProgressHUD showWithStatus:@"Updating" maskType:SVProgressHUDMaskTypeGradient];
[self displaySelected]; // removes current view so you can load hud will not be behind it
if (id == 1) {
[self selectAllD];
} else if (id == 2) {
[self deselectAllD];
} else if (id == 3) {
[self selectAllI];
} else if (id == 4) {
[self deselectAllI];
}
}
as you can see what happens is this method is called when a button is pressed, I would like for the displaySelected method to do what it needs to do before any of the other methods are called?
Currently what happes when i debug this is displaySelected method is called the thread walks through that then continues to the if statment then after the method in the if statment has finished then displaySelected changes are made... its so weird.
any help would be greatly appreciated.
I have to initialize a lot of different types of objects based on an integer parameter. They all have the same overall initialization methods.
At the moment I have the following code
#def APPLE 1
#def PEAR 2
switch (t)
{
case APPLE:
newobj = [[FApple alloc] init];
break;
case PEAR:
newobj = [[FPear] alloc] init];
break;
default:
retobj = nil;
}
I believe there must be a better way to do this. When I add FOrange I have to go and add another line here.
What would be a better way?
Is it just a tab-bar controller that loads some UITableViews that has navigation items set? Or is it a tab-bar controller that is loading a navigation controller?
If I have a custom class Person which has three variables (which are propertized and synthesized):
NSString* theName;
float* theHeight;
int theAge;
Person instances are stored in an NSArray 'Group'. There is only one Group. What is the best way of string and loading the Group in NSUserDefaults? (bearing in mind that float and int are not legal for NSUserDefaults)
Hey All,
i am very new to iphone Development and i am asked to use nsxml parser to parse xml from a google api. i have parsed another url which has xml but i am not able to parse google's because it is using id's to store data rather than inside tag. i.e.
Can somebody help me that how can i parse the attribute inside the tag.
Thanks & Regards
To reproduce this, create a UITableView that contains cells with custom AccessoryViews (such as buttons to perform a specific action where touching the other part of the UITableViewCell should perform a different action).
If you touch (select) the UITableView, the AccessoryView shows selection (as thought it was touched) as well. I want to prevent this and only show the AccessoryView's selected state when they actually touch the AccessoryView.
Thanks in advance,
groomsy
Click the header section(or whatever it calls) will unfold the relative subcells,and the left triangle get rotated.
I have no idea how to code this.Is there anyone help me? Thanks a lot.
I notice something strange happens to one of my view controller: the back button disappears, yet it's possible to go back to previous view controller by tapping the top left corner (i.e where the button should reside).
In my entire file there's no line that set self.navigationItem.hidesBackButton to YES; also NSLog prints 0 as self.navigationItem.hidesBackButton's value in viewDidLoad.
This occurs in both the simulator and real device. Any ideas?
Hi, my problem is that I can't access my NSMutableArray in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {}.
I create my NSMutableArray here:
nodes = [xmlDoc nodesForXPath:@"/xml/items/item/short_desc" error:nil];
if (nodes != nil && [nodes count] >= 1) {
for (int i = 0; i < [nodes count]; i++) {
CXMLElement *resultElement = [nodes objectAtIndex:i];
result = [[[[resultElement attributeForName:@"data"] stringValue] copy] autorelease];
[short_desc addObject:result];
}
}
and I can print out the content of short_desc everywhere with:
NSLog([short_desc objectAtIndex:0]);
but not in:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
.....
NSString *date = [name objectAtIndex:0];
labelDate.text = date;
.....
return cell;}
if I use:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
.....
NSString *date = @"text...";
labelDate.text = date;
.....
return cell;}
it works correctly.
ANY SOLUTION FOR THIS PROBLEM???
I'm trying to resize a UIButton in my iPhone app. I have a UIButton synthesized and when I call the following code, it moves on the screen, but the width & height of the button never change.
button.frame.size = CGRectMake(104, 68, 158, 70);
For example, when I change the height (70) to 40, the height of the button does not change. If I change the x or y, however, it will move on the screen.
Any ideas?
I have a one-to-many relationship where each department has many employees. When I create a new employee object I just link it to the parent department manually by setting the property to the instance of the department I have fetched from my fetch request. However, this seems to be improper because when I try to access the set of employees from the department by simply accessing the .employees property on my department object instance it returns a 0 count. Isn't the fault suppose to fire once I access a property? Am I linking my parent/child objects incorrectly?
I tried setting the color of the backround of the flipsideView in interface builder, but for some reason it doesn't show it in the iphone simulator. It always displays this dark crosshatching backround. How do I get it to display my selected color in the backround?