I want to pass a flag into my location manager function
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
so it will look like
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation andTweet:(Bool *)tweet
but it started with the command
[locmanager stopUpdatingLocation];
So how can I pass the bool into the function?
I have a NSManagedObjectContext in which I have a number of subclasses of NSManagedObjects such that some are containers for others. What I'd like to do is watch a top-level object to be notified of any changes to any of its properties, associations, or the properties/associations of any of the objects it contains.
Using the context's 'hasChanges' doesn't give me enough granularity. The objects 'isUpdated' method only applies to the given object (and not anything in its associations). Is there a convenient (perhaps, KVO-based) was I can observe changes in a context that are limited to a subgraph?
Hi guys,
Little background, the table view is filled by a fetchedResultsController which fills the table view with Strings. Now I'm trying to add a button next to each String in each tableview cell. So far, I've been trying to create a button in my configureCell:atIndexPath method and then add that button as a subview to the table cell's content view, but for some reason the buttons do not show up. Below is the relevant code. If anyone wants more code posted, just ask and I'll put up whatever you want. Any help is greatly appreciated.
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
// get object that has the string that will be put in the table cell
Task *task = [fetchedResultsController objectAtIndexPath:indexPath];
//make button
UIButton *button = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
[button setTitle:@"Check" forState:UIControlStateNormal];
[button setTitle:@"Checked" forState:UIControlStateHighlighted];
//set the table cell text equal to the object's property
cell.textLabel.text = [task taskName];
//addbutton as a subview
[cell.contentView addSubview:button];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
We are caching images downloaded from our server. We write them to our local storage like this:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0] ;
NSString* folder = [[documentsDirectory stringByAppendingPathComponent:@"flook.images"] retain];
NSString* fileName = [folder stringByAppendingFormat:@"/%@", aBaseFilename];
BOOL writeSuccess = [anImageData writeToFile:fileName atomically:NO];
The downloaded images are always the expected size, around 45-85KB.
Later, we read images from our cache like this:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0] ;
NSString* folder = [[documentsDirectory stringByAppendingPathComponent:@"flook.images"] retain];
NSString* fileName = [folder stringByAppendingFormat:@"/%@", aBaseFilename];
image = [UIImage imageWithContentsOfFile:fileName];
Occasionally, the images returned from this cache read are much smaller because they are much more compressed - around 5-10KB. Has the OS done this to us?
Hi there,
I'm using ASIHTTP Request to get a NSString response that I give to a SBJSON parser.
The problem is that inside the NSString response I got some UTF8 encoded character (accent) that I need do decode to make the app works.
How can I decode UTF8 with JSON?
I call the JSON message like this:
[jsonParser objectWithString:jsonString error:NULL];
Any help would be so appreciated.
Fabrizio
I have a simple UITableView setup. I am trying to use
- (void)navigationBar:(UINavigationBar *)navigationBar didPopItem:(UINavigationItem *)item
I put a NSLog inside this method, but it is apparently not getting called when I "pop" back to the screen. I am not finding much information about this function, has it been replaced?
I've created a new app but not uploaded a binary (not ready for review yet).
However, I want to test in-app purchases.
The documentation seems to state that a bundle ID is required to create an in-app purchase product. Is there any way to specify this bundle ID for creating the in-app purchase product on iTunes Connect without uploading the app binary in a way that won't cause problems when the actual binary is uploaded?
What if the eventually uploaded binary has a different bundleID than the use created for testing - does it effectively invalidate the in-app purchase product?
i have performed like this Is there any thing wrong performed by me?
NSURL *url = [NSURL URLWithString:@"http://111.111.111.111/BattleEmpire.Service/ApplicationService.svc?wsdl"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPMethod:@"GET"];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection)
{
webData = [[NSMutableData data] retain];
NSLog( @"connection established");
}
else {
NSLog(@"theConnection is NULL");
}
I want to pass a flag into my location manager function
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
so it will look like
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation andTweet:(Bool *)tweet
but it started with the command
[locmanager startUpdatingLocation];
So how can I pass the bool into the function?
I used core data to do this:
NSManagedObjectContext *m = [self managedObjectContext];
Foo *f = (Foo *)[NSEntityDescription insertNewObjectForEntityForName:@"Foo"
inManagedObjectContext:m];
f.created_at = [NSDate date];
[m insertObject:f];
NSError *error;
[m save:&error];
Where the created_at field is defined as type "Date" in the xcdatamodel.
When I export the sql from the sqlite database it created, created_at is defined as type "timestamp" and the values look like:
290902422.72624
Nine digits before the . and then some fraction.
What is this format? It's not epoch time and it's not julianday format.
Epoch would be:
1269280338.81213
julianday would be:
2455278.236746875 (notice only 7 digits before the . not 9 like I have)
How can I convert a number like 290902422.72624 to epoch time? Thanks!
I have added notification observers for UIDeviceOrientationDidChangeNotification in my appDelegate. But it is not getting called when movieplayer is visisble. But works fine with other views.
Been working on this problem of collision detection and there appears to be 3 main approaches I could take:
Sprite and mask approach. (AND the overlap of the sprites and check for a non-zero number in the resulting sprite pixel data).
Bounding circles, rectangles or polygons. (Create one or more shapes that enclose the sprites and do the basic maths to check for overlaps).
Use an existing sprite library.
The first approach, even though it would have been the way I would have done it in the old days of 16x16 sprite blocks, it appears that there just isn’t an easy way of getting at the individual image pixel data and/or alpha channel within Quartz (or OPENGL for that matter). Detecting the overlap of the bounding box is easy, but then creating a 3rd image from the overlap and then testing it for pixels is complicated and my gut feel is that even if we could get it to work would be slow. Am I missing something neat here?
The second approach involves dividing up our sprites into several polygons and testing them for overlaps. The more polygons the more accurate the collision detection. The benefit is that it is fast, and can be accurate. The downside is it makes the sprite creation more complicated. i.e., we have to create the polygons for each sprite. For speed the best approach is to create a tree of polygons.
The 3rd approach I’m not sure about as it involves buying code (or using an open source licence). I am not sure what the best library to use is or whether this would make life easier or give us a problem integrating this into our app.
So in short I am favouring the polygon and tree approach and would appreciate you views on this before I go and write lots of code.
Best regards
Dave
I have been assigned an 'easy' task of adding a button over a playing video.
I m terming it easy as i have got the sample code downloaded from Apple's sample code.
http://rapidshare.com/files/393248642/MoviePlayer_iPhone.zip
Anybody who wants to reply to my query and intends to help should download this project and run it otherwise it wudnt be easy to understand my problem. Thanks!
And now the weird problem i am facing is:
In the sample project developer has added the view ( UILabel and UIButton ) in the Appdelegate.
And i want it other xib files not the App delegate .
Fine i added a view 'myButtonABC' instead of 'My Overlay View'.
And added this code in my xib file's implementation file.
(void)viewDidLoad
{
TaimurAppDelegate *appDelegate = (TaimurAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate initAndPlayMovie:[self localMovieURL]];
NSArray *windows = [[UIApplication sharedApplication] windows];
if ([windows count] 1)
{
UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
[moviePlayerWindow addSubview:self.myABC];
}
}
Now my question is do i need to declare a UIWindow object in the header file here. As i am not working in the app delegate class. As i said previously i have to add this button over a video in other screen and not on the main screen.
The third question is can anyone, which in fact is the most imp of all. In my view , if i am able to do this one my problem would be solved. As i have spend considerable amount of time on this task so far. The question is " How can i connect myABCButton (which is a view added to my xib file ) to the File's Owner.
Thanks for your patience.
Replies Appreciated !
Taimur
Hi i am developing an app for my QA department. I need to programically get how many phone numbers are there in the entire address book. No user input. Just click a button and then get how many phonenumbers are there in the ENTIRE addressbook.
Please email me at [email protected]
I feel like this should be obvious to me, but for some reason I can't figure this out. I have a navigation interface with nav bar, tool bar, and primary view. Sometimes the user takes an action that causes a progress indicator to appear in the middle of the view.
While the progress indicator (which is a custom UIView) in spinning in the middle, I want no touch input to be allowed to go to any of the underlying interface (main view, nav bar, toolbar, etc). But this doesn't seem trivial.
I've tried (and failed) to create a simple view whose only job is to swallow touch input and use it as a window subview-- no dice, it never gets the touch events (and yes, it does have userInteractionEnabled). I've tried to bolt it on as a transparent modal view controller, but those don't seem to ever be transparent.
Thoughts? What am I missing?
Thanks!
I notice that this method is provided in UIViewController .m files, but is commented out:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
I had been leaving that method commented out, or even deleting it. But then I looked at this line inside the method:
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
I assume that if it were truly important for self to be set equal to super, then Apple would not have the method be commented out by default. On the other hand, if I do need to do some customization in that method, why do I need to set self = super? What's the best practice, and why?
Hi Everybody,
I am trying to upload a image which i am clicking with the help of the camera. I am trying the following code to upload the image to the remote server.
-(void)searchAction:(UIImage*)theImage
{
UIDevice *dev = [UIDevice currentDevice];
NSString *uniqueId = dev.uniqueIdentifier;
NSData * imageData = UIImagePNGRepresentation(theImage);
NSString *postLength = [NSString stringWithFormat:@"%d",[imageData length]];
NSString *urlString = [@"http://www.amolconsultants.com/im.jsp?" stringByAppendingString:@"imagedata=iPhoneV0&mcid="];
urlString = [urlString stringByAppendingString:uniqueId];
urlString = [urlString stringByAppendingString:@"&lang=en_US.UTF-8"];
NSLog(@"The URL of the image is :- %@", urlString);
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:imageData];
NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:request delegate:self];
if (conn == nil)
{
NSLog(@"Failed to create the connection");
}
}
But nothing is getting posted. Nothing comes in the console window also. I am calling this method in the action sheet. When the user clicks on the 1st button of the action sheet this method is called to post the image.
Can anyone help me with this...
Any code will be very helpful...
Thanx in advance...
Have: xCode project with Google Analytics lib, could be normally compiled. Want just to put it to already working SVN to build project from the work macosx without any additional steps.
I've tried different ways to add *.a file to the svn, but all just have not worked. When adding a directory there is all files except *.a in the svn.
I bet there is not such problem with 3d party SVN clients, but want to give the xCode one more chance, so asking there.
Guys, is it possible to add *.a files to SVN using xCode?
Hi,
I am using the accelerometer to move a few UIImageViews around the screen, at the moment the accelerometer only works when a NSTimer is at 0, this is fine. I would also like to make the accelerometer stop again when a different function happens.
here is my code at the moment:
-(BOOL) accelerometerWorks {
return time == 0;
}
-(void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{
if(![self accelerometerWorks]) return;
valueX = acceleration.x*25.5;
int newX = (int)(ball.center.x +valueX);
if (newX 320-BALL_RADIUS)
newX = 320-BALL_RADIUS;
if (newX < 0+BALL_RADIUS)
newX = 0+BALL_RADIUS;
int XA = (int)(balloonbit1.center.x +valueX);
if (XA 320-BALL_RADIUS)
XA = 320-BALL_RADIUS;
if (XA < 0+BALL_RADIUS)
XA = 0+BALL_RADIUS;
int XB = (int)(balloonbit2.center.x +valueX);
if (XB 320-BALL_RADIUS)
XB = 320-BALL_RADIUS;
if (XB < 0+BALL_RADIUS)
XB = 0+BALL_RADIUS;
int XI = (int)(balloonbit3.center.x +valueX);
if (XI 320-BALL_RADIUS)
XI = 320-BALL_RADIUS;
if (XI < 0+BALL_RADIUS)
XI = 0+BALL_RADIUS;
int XJ = (int)(balloonbit4.center.x +valueX);
if (XJ 320-BALL_RADIUS)
XJ = 320-BALL_RADIUS;
if (XJ < 0+BALL_RADIUS)
XJ = 0+BALL_RADIUS;
int XE = (int)(balloonbit5.center.x +valueX);
if (XE 320-BALL_RADIUS)
XE = 320-BALL_RADIUS;
if (XE < 0+BALL_RADIUS)
XE = 0+BALL_RADIUS;
int XF = (int)(balloonbit6.center.x +valueX);
if (XF 320-BALL_RADIUS)
XF = 320-BALL_RADIUS;
if (XF < 0+BALL_RADIUS)
XF = 0+BALL_RADIUS;
int XH = (int)(balloonbit8.center.x +valueX);
if (XH 320-BALL_RADIUS)
XH = 320-BALL_RADIUS;
if (XH < 0+BALL_RADIUS)
XH = 0+BALL_RADIUS;
ball.center = CGPointMake (newX, 429);
balloonbit1.center = CGPointMake (XA, 429);
balloonbit2.center = CGPointMake (XB, 426);
balloonbit3.center = CGPointMake (XI, 410);
balloonbit4.center = CGPointMake (XJ, 415);
balloonbit5.center = CGPointMake (XE, 409);
balloonbit6.center = CGPointMake (XF, 427);
balloonbit8.center = CGPointMake (XH, 417);
}
This all works fine, i would now like to stop the accelerometer from working, using the same
accelerometerWorks method or a new method, accelerometerWontWork.
This is the code that when it is called i would like the accelerometer to stop. (it is very long so i wont put all of it there, but its all the same throughout):
-(void) checkCollision{
if (CGRectIntersectsRect(pinend.frame, balloonbit1.frame)){
if (balloonbit1.frame.origin.y pinend.frame.origin.y){
[maintimer invalidate];
levelfailed.center = CGPointMake (160, 235);
}
}
if (CGRectIntersectsRect(pinend.frame, balloonbit2.frame)){
if (balloonbit2.frame.origin.y pinend.frame.origin.y){
[maintimer invalidate];
levelfailed.center = CGPointMake (160, 235);
}
}
if (CGRectIntersectsRect(pinend.frame, balloonbit3.frame)){
if (balloonbit3.frame.origin.y pinend.frame.origin.y){
[maintimer invalidate];
levelfailed.center = CGPointMake (160, 235);
}
}
}
I understand that i may have to turn this into a BOOL. Thats fine.
If i haven't explained it well please say and i will re write it.
Thanks!
Harry.