objective-c

How to get the amount of free virtual memory on Apple / Mac?

How do I get the amount of free virtual memory on Mac OSX? I'm speaking of total free virtual memory (or: free addresses) and also the biggest allocatable continous block of memory available for the current process. (Like e.g. on Windows returned by GlobalMemoryStatus (free mem) or querieable with a combination of GetSystemInfo / Virt...

How to add and delete items in an array from inside a child view

Let's say I declare an NSMutableArray in the class file foo.h. Then in the viewDidLoad method in foo.m I populate the array. Inside foo.m I can add, delete, or modify array elements. Then let's say the following code executes inside foo.m [self.navigationController pushViewController:bar animated:YES]; This will switch the view and p...

Benefits of creating iPhone, iPad and Mac apps with Cocoa over Sproutcore+Phonecap/Titanium?

I'm going to create iPhone and Mac apps and wonder if there are benefits of creating iPhone and Mac apps with Cocoa over Sproutcore + Phonegap/Titanium? I'm not doing any game or high performance related software. If I learn Cocoa I could only create apps for iPhone, iPad and Mac. But if I use Sproutcore for web development with Phoneg...

Replace multiple groups of characters in an NSString

I want to replace several different groups of characters in one NSString. Currently I am doing it with several repeating methods, however I am hoping there is a way of doing this in one method: NSString *result = [html stringByReplacingOccurrencesOfString:@"<B&" withString:@" "]; NSString *result2 = [result stringByReplacingOccurren...

why lost data when get from plist file

I have NSMutableArray *arrTest = [[NSMutableArray arrayWithObjects:@"value 1",@"value 2", @"value 3",@"value 4",nil] retain]; I stored my array to plist file (ex: sample.plist).-> ok I call a method to get that arrTest from above plist file -> ok. i use that arrTest to display data in UITableView. but a...

Weird problem using UINib / pointer going AWOL

I have something weird going on with using UINib, although I suspect the real problem may be buried elsewhere. My app is using a tableview, the content for the cells has been prepared in Interface Builder due to their complexity. For new cells (as opposed to reused ones), the contents of the nib are instantiated using the UINib Class. B...

Related to current location latitude and longitute.

Hi All,I have Problem with get current locations latitide and longitude. My code is described in below: (void)viewDidLoad { [super viewDidLoad]; locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move locationManager.desiredAccura...

How to parse complex XML tree using TouchXml in iPhone.

Hi all, I am trying to build an app which during start-up connects to website and downloads the XML data. Though the data is large(100 KB) and i am using TouchXml for it. The xml is like this. <?xml version="1.0" encoding="UTF-8"?> <itemA attA="AAA" attB="BBB" attC="CCC"> <itemB> <itemC1 attD="DDD" attE="EEE" attF="FFF...

This piece of C/Obj-C code puzzles me

I've this simple method to shift element in an array. void queuePut(uint32_t val, uint32_t *q, int qlen) { for (int i=qlen; i>0; i--) { q[i] = q[i-1]; } q[0] = val; } In my class header i defined a struct @interface MyClass : NSObject { struct { uint32_t cookie[10]; uint32_t value[10]; } qu...

Redefine / resize C array in Objective C?

I have a C array in Objective C defined as follows: id keysArray; Then in an if block, i would like to redefine the array based on a condition: if (somethingIsTrue){ id keysArray[4][3]; } else { id keysArray[6][1]; } Then outside of the if block, when i access the array, i get errors saying the keysArray does not exist. Th...

releasing and retaining NSString* properly

Hi all i'm still new to iPhone development, but had strong experience with other programming languages. The thing that makes me pull my hair out is the Obj-C memmory management and releasing / retaining properly. I know the concept, i know "once i understand it will be easy" but i'm not quite still there, and that makes me crazy. Here i ...

recognize the face & distort it

Hello, We have to create an application which can take a photograph and can recognize the face and can distort it in a certain way. Below is an example: http://itunes.apple.com/us/app/fatbooth/id372268904?mt=8 Any ideas ? is it possible using OpenCV library only ? Thanks Tariq ...

Do I need to convert NSUInteger to size_t?

If I have the following code: NSUInteger i, count = [pages count]; for (i = 0; i < count; i++) { Page* page = (Page *)[pages objectAtIndex:i]; [page setPageNumber:[i unsignedIntValue]]; } PageInfo.pageNumber is a size_t. Is it still necessary to use [i unsignedIntValue] or do I just assign i directly? ...

Is this a valid way to build and send NSData through GameKit?

Hi guys, Its y first time trying to use NSData and Gamekit. So was wondering am i packing the data properly? - (void)sendNetworkPacket:(GKSession *)session packetID:(int)packetID reliable:(BOOL)howtosend { // the packet we'll send is resued static unsigned char networkPacket[kMaxTankPacketSize]; const unsigned int packetHeaderSize =...

Programmatic View Offset by Status Bar?

I am just looking at setting a up a custom UIViewController programatically (see code below) and I am just curious about the white line I am getting at the bottom of the display, I don't see this when I create the view using a NIB in InterfaceBuilder. Is it just a case of offsetting the frame down by the height of the status bar or am I ...

DIV wont work with float objective c

Hi I'm trying to use: float divAm = (float)theAngle%(float)rads; but its saying that Invalid operands to binary % theAngle and rads are both of type float. Any suggestions please? Thanks ...

Screen Resolutions and Frame Size?

I am curious about how the iPhone4 works out the size of frame items, for example: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { MyController *tempController = [[MyController alloc] init]; [[tempController view] setFrame:CGRectMake(0.0,20.0,320.0,460.0)]; [self...

Problem in memory manegment?

Hi, I developing an application, in which i working with database manipulation. The method i have written in database class as follows. -(NSMutableArray *)getData: (NSString *)dbPath{ NSMutableArray *dataArray = [[NSMutableArray alloc] init]; if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK){ NSString *sqlQu...

Build a IS-A relationship with coredata

Hi, i need to set up a IS-A relationship with coredata. I have a Page class which has the following structure PROPERTY title PROPERTY layoutType RELATIONSHIP layout Now, i have three classes: ImageLayout, TextLayout, and SlideshowLayout. I want the Page.layout relationship to refer to one of these three classes depending on the layou...

shared static function in objective-c iphone?

I need to calculate from pricing based on some business rules and I do not want to duplicate this across several ViewControllers. Coming from a .Net world I would use a static method on a class to do this. What is a similar solution in Objective-C? ...