After testing my app with Instruments I realized that the current CSV parser I use has a huge memory footprint. Does anybody have a recommendation for one with a low memory footprint?
I have a function that updates the gps coordinate lat and long then sends a tweet with the lat and long info attached. I want the function to wait until the lat and long are filled before the tweet goes through but it seems to do both at the same time so the lat and long don't get filled in. How do I make the gps location update first?
Hi there,
I've set up a grouped table on my app, and pushing to new views works fine. Except for one thing. The titles and stack layout are all weird. Here's the breakdown:
I have two sections in my table.
When I tap on the first row in the first section, it takes me to the correct view, but the title of the new view is the name of the first row in the second section of the table.
In turn, the second row in the first section's title is the second row in the second section's title.
If I tap on the second row in the second section of the root view table, the navigation button goes to the second row in the first section of the table.
So here's a diagram of my table:
Table Section 1
Row 1
Row 2
Row 3
Table Section 2
Row A
Row B
Row C
So if I tap on row 3, the title of the pushed view is Row C. The navigation button tells me to go back to Row 3, then eventually ending up at the root view.
Here's my implementation file pushing the views:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//CSS
if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"CSS"])
{
CSSViewController *css = [[CSSViewController alloc] initWithNibName:@"CSSViewController" bundle:nil];
[css setTitle:@"CSS"];
[self.navigationController pushViewController:css animated:YES];
}
//HTML
if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"HTML"])
{
HTMLViewController *html = [[HTMLViewController alloc] initWithNibName:@"HTMLViewController" bundle:nil];
[html setTitle:@"HTML"];
[self.navigationController pushViewController:html animated:YES];
}
//JS
if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"JavaScript"])
{
JSViewController *js = [[JSViewController alloc] initWithNibName:@"JSViewController" bundle:nil];
[js setTitle:@"JavaScript"];
[self.navigationController pushViewController:js animated:YES];
}
//PHP
if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"PHP"])
{
PHPViewController *php = [[PHPViewController alloc] initWithNibName:@"PHPViewController" bundle:nil];
[php setTitle:@"PHP"];
[self.navigationController pushViewController:php animated:YES];
}
//SQL
if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"SQL"])
{
SQLViewController *sql = [[SQLViewController alloc] initWithNibName:@"SQLViewController" bundle:nil];
[sql setTitle:@"SQL"];
[self.navigationController pushViewController:sql animated:YES];
}
& the array feeding the table's data:
- (void)viewDidLoad {
[super viewDidLoad];
arryClientSide = [[NSArray alloc] initWithObjects:@"CSS",@"HTML",@"JavaScript",nil];
arryServerSide = [[NSArray alloc] initWithObjects:@"Objective-C", @"PHP",@"SQL",nil];
// arryResources = [[NSArray alloc] initWithObjects:@"HTML Colour Codes", @"Useful Resources", @"About",nil];
self.title = @"Select a Language";
[super viewDidLoad];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
Any help would be greatly appreciated.
Jack
I have BaseView which implement UIViewController. Every view in project must implement this BaseView.
In BaseView, I have method:
-(void) checkLoginStatus
{
defaults = [[NSUserDefaults alloc] init];
if(![[defaults objectForKey:@"USERID"] length] > 0 )
{
Login *login=[[Login alloc] initWithNibName:@"Login" bundle:nil];
[self.navigationController pushViewController:login animated:TRUE];
[login release];
}
[defaults release];
}
The problem is my Login view also implement BaseView, checks for login, and again open LoginView i.e. stuck in to recursive calling.
Can I check in checkLoginStatus method if request is from LoginView then take no action else check login.
Ex:
(void) checkLoginStatus
{
if(SubView is NOT Login){
defaults = [[NSUserDefaults alloc] init];
if(![[defaults objectForKey:@"USERID"] length] 0 )
{
Login *login=[[Login alloc] initWithNibName:@"Login" bundle:nil];
[self.navigationController pushViewController:login animated:TRUE];
[login release];
}
[defaults release];
}
}
Please help..
I'm pushing a UITableViewController onto a navigationController. The title (set in the viewDidLoad) shows up but not the table.
numberOfSectionsInTableView is called. But tableView:numberOfRowsInSection: is not called. I'm passing in 1 so it should be looking for number of rows.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
I'm setting up the view in the following manner:
SelectUserViewController *nextController = [[SelectUserViewController alloc] initWithStyle:UITableViewStyleGrouped];
nextController.managedObjectContext = managedObjectContext;
OrangeQCAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.navigationController pushViewController:nextController animated:YES];
Again, the viewDidLoad method is called. And my class is set up as follows:
@interface SelectUserViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {...}
What else should I be looking at? When I go through the debugger, after it looks at numberOfSectionsInTableView it just disappears (I think it is in the UITableViewController class) and never comes back.
hello,
On reading the iTunesConnect_DeveloperGuide.pdf, i came across the term binary. This is the paragraph found in the pdf:
To submit your application through iTunes Connect and get it posted on the
App Store successfully, make sure you have the following:
Application binary (includes 57px icon), large 512px icon for use on the App Store,
primary screenshot, contract information, export compliance information and applica-
tion metadata
It is also mentioned that the binary should be a zipped file.
Can anyone please explain what is a binary and how to create one?
Thanks
I am looking to build a web app that implements background audio and fast app switching. These features work out of the box, when run as regular Safari web pages, but as soon as you add the web-app-capable tag, and try to run in full screen mode, this functionality breaks.
I did some testing and even the most basic web app will reload every time when you switch back to it. And seeing as it's a web app, we can't exactly implement the multitasking API. Has anyone found a work around?
This isn't a deal-breaker, as you can just avoid full screen mode, but then you also lose the ability to use your own icon in the app switch tray. Perhaps this explains a lack of full screen mode in YouTube's new web app....
Has any one got a working code sample for mpoauthconnection.
I had checkout source from code.google.com/p/mpoauthconnectio.
But selecting MPAouthTestApp gives the following error.
target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphonesimulator' platform
Please help me to solve the error or can anyone provide me with a sample working code for mpoauthconnection.
My email id is [email protected]
Is there a way to set a default position for a UIPicker? I mean, if the user has the option of selecting any number from 1 to 100 in the UIPicker, can I set it to automatically start at 50?
Gday, I am trying to create a tiled map for my game, i have had this previously working using other xml methods but i had memory leaks and all sorts of errors. However i had a map load time of about 2.5 - 3 seconds.
So i rewrote all of the code using NSMutableStrings and NSStrings. After my best attempt at optomizing it i had a map load time of 10 - 11 seconds, which is far too slow.
So i have now rewritten the code using char* arrays, only to now have a load time of 18 seconds -_-.
Here is the latest code, i don't know much c so i could have easily botched the whole thing up.
FILE* file = fopen(a, "r");
fseek(file, 0L, SEEK_END);
length = ftell(file);
fseek(file,0L, SEEK_SET);
char fileText[length +1];
char buffer[1024];// = malloc(1024);
while(fgets(buffer, 1024, file) != NULL)
{
strncat(fileText, buffer, strlen(buffer));
}
fclose(file);
[self parseMapFile:fileText];
- (void)parseMapFile:(char*)tiledXML
{
currentLayerID = 0;
currentTileSetID = 0;
tileX = 0;
tileY = 0;
int tmpGid;
NSString* tmpName;
int tmpTileWidth;
int tmpTileHeight;
int tilesetCounter = 0;
NSString* tmpLayerName;
int tmpLayerHeight;
int tmpLayerWidth;
int layerCounter = 0;
tileX = 0;
tileY = 0;
int tmpFirstGid = 0;
int x;
int index;
char* r;
int counter = 0;
while ((x = [self findSubstring:tiledXML substring:"\n"]) != 0)
{
counter ++;
char result[x + 1];
r = &result[0];
[self substringIndex:tiledXML index:x newArray:result];
tiledXML += x+2;
index = 0;
if (counter == 1)
{
continue;
}
else if (counter == 2)
{
char result1[5];
index = [self getStringBetweenStrings:r substring1:"th=\"" substring2:"\"" newArray:result1];
if (r != 0);
mapWidth = atoi(result1);
r += index +1;
index = 0;
index = [self getStringBetweenStrings:r substring1:"ht=\"" substring2:"\"" newArray:result1];
if (r != 0);
mapHeight = atoi(result1);
r += index +1;
index = 0;
index = [self getStringBetweenStrings:r substring1:"th=\"" substring2:"\"" newArray:result1];
if (r != 0);
tileWidth = atoi(result1);
r += index +1;
index = 0;
index = [self getStringBetweenStrings:r substring1:"ht=\"" substring2:"\"" newArray:result1];
if (r != 0);
tileHeight = atoi(result1);
continue;
}
char result2[50];
char result3[3];
if ((index = [self getStringBetweenStrings:r substring1:" gid=\"" substring2:"\"" newArray:result3]) != 0)
{
tmpGid = atoi(result3);
free(result2);
if(tmpGid == 0)
{
[currentLayer addTileAtX:tileX y:tileY tileSetID:-1 tileID:0 globalID:0];
}
else
{
[currentLayer addTileAtX:tileX
y:tileY
tileSetID:[currentTileSet tileSetID]
tileID:tmpGid - [currentTileSet firstGID]
globalID:tmpGid];
}
tileX ++;
if (tileX > [currentLayer layerWidth]-1)
{
tileY ++;
tileX = 0;
}
}
else if ((index = [self getStringBetweenStrings:r substring1:"tgid=\"" substring2:"\"" newArray:result2]) != 0)
{
tmpFirstGid = atoi(result2);
r += index +1;
index = 0;
index = [self getStringBetweenStrings:r substring1:"me=\"" substring2:"\"" newArray:result2];
if (r != 0);
tmpName = [NSString stringWithUTF8String:result2];
r += index +1;
index = 0;
index = [self getStringBetweenStrings:r substring1:"th=\"" substring2:"\"" newArray:result2];
if (r != 0);
tmpTileWidth = atoi(result2);
r += index +1;
index = 0;
index = [self getStringBetweenStrings:r substring1:"ht=\"" substring2:"\"" newArray:result2];
if (r != 0);
tmpTileHeight = atoi(result2);
}
else if ((index = [self getStringBetweenStrings:r substring1:"rce=\"" substring2:"\"" newArray:result2]) != 0)
{
currentTileSet = [[TileSet alloc] initWithImageNamed:[NSString stringWithUTF8String:result2] name:tmpName tileSetID:tilesetCounter firstGID:tmpFirstGid tileWidth:tmpTileWidth tileHeight:tmpTileHeight spacing:0];
[tileSets addObject:currentTileSet];
[currentTileSet release];
tilesetCounter ++;
}
else if ((index = [self getStringBetweenStrings:r substring1:"r name=\"" substring2:"\"" newArray:result2]) != 0)
{
tileX = 0;
tileY = 0;
tmpLayerName = [NSString stringWithUTF8String:result2];
r += index +1;
index = 0;
index = [self getStringBetweenStrings:r substring1:"th=\"" substring2:"\"" newArray:result2];
if (r != 0);
tmpLayerWidth = atoi(result2);
r += index +1;
index = 0;
index = [self getStringBetweenStrings:r substring1:"ht=\"" substring2:"\"" newArray:result2];
if (r != 0);
tmpLayerHeight = atoi(result2);
currentLayer = [[Layer alloc] initWithName:tmpLayerName layerID:layerCounter layerWidth:tmpLayerWidth layerHeight:tmpLayerHeight];
[layers addObject:currentLayer];
[currentLayer release];
layerCounter ++;
}
}
}
-(void)substringIndex:(char*)c index:(int)x newArray:(char*)result
{
result[0] = 0;
for (int i = 0; i < strlen(c); i++)
{
result[i] = c[i];
if (i == x)
{
result[i+1] = '\0';
break;
}
}
}
-(int)findSubstring:(char*)c substring:(char*)s
{
int sCounter = 0;
int index = 0;
int d;
for (int i = 0; i < strlen(c); i ++)
{
if (i > 500)//max line size
break;
if (c[i] == s[sCounter])
{
d = strlen(s);
sCounter ++;
if (d > sCounter)
{
}
else
{
index = i - (d);
break;
}
}
else
sCounter = 0;
}
return index;
}
-(int)getStringBetweenStrings:(char*)c substring1:(char*)s substring2:(char*)s2 newArray:(char*)result
{
int sCounter = 0;
int sCounter2 = 0;
int index = 0;
int index2 = 0;
int d;
for (int i = 0; i < strlen(c); i ++)
{
if (index != 0)
{
if (c[i] == s2[sCounter2])
{
d = strlen(s2);
sCounter2 ++;
if (d > sCounter2)
{
}
else
{
index2 = i - (d);
break;
}
}
else
sCounter2 = 0;
}
else
{
if (c[i] == s[sCounter])
{
d = strlen(s);
sCounter ++;
if (d > sCounter)
{
}
else
{
index = i;
}
}
else
sCounter = 0;
}
}
if (index != 0 && index2 != 0)
[self substringIndex:(c + index+1) index:index2-index-1 newArray:result];
return index;
}
(I know it's a lot of code to be putting in here)
I thought the by using basic char arrays i could drastically increase the performance, at least over the initial node based code that i was replacing.
Thanks for all your efforts.
I'd like to use use maps in my application, so that there will be as less as possible traffic. Perfect solution would be caching of map slices. I know it's not possible with google maps (license). I took a look on OpenStreetMaps and it seems as good solution. The next: SDK. The only one I've found is from CloudMade. The problem is, I found no related API methods for caching/offline calls.
Are there any alternative solutions?
Hello all,
In my current application I want to show a songs list in table view which is pretty easy but on selection of one of the songs it should be played in media player .
How can I do so .
Provide me if anyone have good tutorial or example link
I have tried to use twitter API in my application using MGTwiiterEngine, I think Ih ave configured all thing but while I am running the app by giving my username and password. The delegate of the MGTwitterEngine was called with the 0 statuses and also the numberOfConnections=0.
twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
[twitterEngine setUsername:username password:password];
[twitterEngine getRepliesStartingAtPage:0];
Can any one please help me out.
Thanks in advance
Hi,
I only started with sdk but this problem is bugging me now for a view days:
I created a UITableView and added it to my Tabs. When this TableView is in the first 4 Tabs and u go look at it, it only shows the items on the table but when clicking on them nothing happens (it doesn't go to the next view).
BUT when i put this same tab behind the 5th so it goes in the automatic MORE view everything works fine. I'm assuming this is because this more view is implementing some kind of table class.
But i can't figure it out. I compared all the files with a working example but it seems to be all the same.
ah ya my current project is a window based application. Though i copied most of the code from a navigation based application.
Any ideas?
I am new to objective C, So maybe there is some basic thing that I am missing about selectors. I would like to understand the basic concept behind this error as I have not found an general error reference.
I am getting this error when using:
[CloseButton addTarget:PageContents action:@selector(CloseButtonPressed) forControlEvents:UIControlEventTouchUpInside];
and then later:
- (void)CloseButtonPressed:(id)sender{
UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"Comment" message: @"hello" delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[someError show];
[someError release];
}
I logged into my account and is reaching this page.
http://developer.apple.com/devforums/
After that when i click login and give the details, it redirects to the same page.
Where can I see the discussions and post questions?
I know its a simple question but dont know what I am missing here.
I want to get the volume or even how much noise is coming through the mic. So someone is talking or some noise is going on in the background I want to know how much. Which framework would I use: Audio Toolbox, Audio Unit, AV Foundation, and Core Audio
I'm using core data and fetching the results successfully. I've few questions regarding core data
1. When I add a record, will it be added at the end or at the start of entity.
2. I'm using following code to fetch the data. Array is being populated with all the records. But they are not in the same order as I entered records into entity. why? on what basis default sorting is used?
NSFetchRequest* allLatest = [[NSFetchRequest alloc] init];
[allLatest setEntity:[NSEntityDescription entityForName:@"Latest" inManagedObjectContext:[self managedObjectContext]]];
NSError* error = nil;
NSArray* records = [managedObjectContext executeFetchRequest:allLatest error:&error];
[allLatest release];
3. The way that I enter the records, 1,2,3,4......... after some time, I want to delete the records that I entered first(i mean oldest data). Something like delete oldest two records. How to do it?
I am using below formula to move the ball circular, where accelX and accelY are the values from accelerometer, it is working fine.
But the problem in this code is mRadius(I fixed its value to 50), i need to change mRadius according to accelerometer values and also i need bouncing effect when it touches other circles please send your answers ASAP... I am waiting.
float degrees = -atan2(accelX, accelY) * 180 / 3.14159;
int x = cCentrePoint.x + mRadius * cos(degreesToRadians(degrees));
int y = cCentrePoint.y + mRadius * sin(degreesToRadians(degrees));
Here is the snap of the game i want to develop.
http://iphront.com/wp-content/uploads/2009/12/bdece528ea334033.jpg.jpg
Hello everyone
I have this code below:
NSString *fileName = [[NSUserDefaults standardUserDefaults] objectForKey:@"recentDownload"];
NSString *fullPath = [NSBundle pathForResource:fileName ofType:@"txt" inDirectory:[NSHomeDirectory() stringByAppendingString:@"/Documents/"]];
NSError *error = nil;
[textViewerDownload setText:[NSString stringWithContentsOfFile:fullPath encoding: NSUTF8StringEncoding error:&error]];
textviewerdownload is the textview displaying the text from the file. The actual file name is stored in an NSUserDefault called recentDownload.
When I build this, I click the button which this is under, and my application crashes.
Is there anything wrong with the syntax or just simple error?
NSArray *results = [managedObjectContext executeFetchRequest:request error:&error];
if(results == nil){
NSLog(@"No results found");
searchObj = nil;
}else{
if ([[[results objectAtIndex:0] name] caseInsensitiveCompare:passdTextToSearchFor] == 0) {
NSLog(@"results %@", [[results objectAtIndex:0] name]);
searchObj = [results objectAtIndex:0];
}else {
NSLog(@"No results found");
searchObj = nil;
}
}
The code above compares data a user enters to data pulled from a database. If I enter data which is in the database; it works. But if I enter complete gibberish it returns the error below instead of "No results found."
*** WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate: <NSRangeException> *** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)
The results array being null should be accounted for during the checks in the above code, no?
I wish to plot a line graph where the x-axis is defined as a number of days between two dates and the y-axis is a value that varies on each of the days.
I can plot the y values as an NSNumber but I have no idea how to set the ranges and the markup on the x-axis. I have looked at the date example in the "examples" directory of the core-plot distribution but have found it a little confusing.
Does anyone know of a tutorial, or code sample, which might asist me in this regard?
Thank you in advance.