Seems like a simple thing but I can't seem to find a way to do it.
I saw this but it doesn't seem to work:
NSDate *date = [NSDate dateWithNaturalLanguageString:@"07/17/07"];
It would be great to see a couple different methods.
Thanks,
Nick
Hi, I am trying to set up an application in which users will be able to stream music. When the user is streaming a MP3, I'd like to set up a link to the iTunes store to buy the MP3.
How can I do that? I feel like there should be some simple way of doing so using the song title and artist name, am I mistaking?
Thanks
Does someone knows how we can combine our current recording into another background playing music? I need some sample code for this. I want to create something like karaoke application in which we can record our voice over an instrumental music.
Currently I am loading my supported products from a plist and after that I send a SKProductsRequest to guarantee that my SKProducts are still valid.
So I set up the request, start it and get the response in:
(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
Now, so far all functions correctly.
Problem: From calling the request until receiving the response it may last several seconds. Until that my app is already loaded and the user may be able to choose and buy a product.
But because no products have been received, the available products are not in sync with the validated products - unlikely, but possible error.
So my idea is to wait until the data is loaded and only continue when the list is validated.
(Just a few seconds waiting...). I have a singleton instance managing all products.
+ (MyClass *) sharedInstance
{
if (!sharedInstance)
sharedInstance = [MyClass new];
// Now wait until we have our data
[condition lock];
while (noEntriesYet) // is yes at begin
[condition wait];
[condition unlock];
return sharedInstance;
}
- productsRequest: didReceiveResponse:
{
[condition lock];
// I have my data
noEntriesYet = false;
[condition signal];
[condition unlock];
}
Problem: The app freezes. Everything works fine if didReceiveResponse is completed before
the sharedInstance is queried. There are different threads, the lock is working if
wait is reached during didReceiveResponse, everything fine. But if not, didReceiveResponse
is never called even if the request was sent.
The lock is released, everything looks ok. I have tried to send the product request in a separate NSThread, with NSOperationQueue...without avail.
Why ? What is happening ?
How to solve the problem ?
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?
It is my understanding that currently if you use UIImagePicker to grab a photo, it passes back back a UIImage object which doesn't include any of the geotagging information. I was wondering if it's confirmed that in OS 4 this is fixed? Or any suggestions on where to go look to see if this is fixed?
Thanks, Mark
I need to work with private HTTPS API and client has incorrect certificate on the host.
Certificate is for www.clienthost.com and I'm working with api.clienthost.com.
So I need to connect via HTTPS to api.clienthost.com ignoring incorrect certificate but still make sure it is the one for www.clienthost.com and not something else.
I found this answer: http://stackoverflow.com/questions/933331/how-to-use-nsurlconnection-to-connect-with-ssl-for-an-untrusted-cert and it seems to solve half of my problem but I'm trying to figure out how to still check certificate for host is one I expect to see and not different.
Hi
I have to do some different views containing 72 LED lights. I built an LED Class so I can loop through the LED's and set them to different colors (Green, Red, Orange, Blue None etc.).
The LED then loads the appropriate .png.
This works fine, I loop over the LED's and set them.
Now I know that at some time they will need to not just turn on/off change color, but will have to turn on with a small delay. Like an equalizer.
I have a 5-10 views containing the 72 LED's and I would like to achieve the above with the minimum amount of memory/CPU strain.
for(LED *l in self.ledArray) {
[l display:Green];
}
I simply loop as shown above and inside the LED is a switch case that does the correct logic.
If this were actual LED's and a microController I would use sleep(100) or similar in the loop, but I would really like to avoid stuff like that for obvious reasons.
I was thinking that doing a performOnThread withDelay would really be consuming, so would UIView animation changing the alpha and NSOperation would also be a lot of lifting for a small feature.
Is there a both efficient and clever way to go around this?
Thanks for any inspiration given:)
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 am modifying the "MoveMe" example from the apple web site. When I get the "touchesMoved" message I move the centre of the target view to the centre of the touch.
Is there a way that when the touch starts ("touchesBegan" message) I can remember the offset from the target view and keep that offset.
Let me know if this is hard to understand and I will try to explain it a bit better.
I'm loading profile pictures from Facebook, cache them on disk and load them into cells of a UITableView.
Now I'm wondering, how I can find out when someone has changed his/her profile picture on Facebook that I have to load the new image from the web instead of using the one cached disk.
The url of the image is always the same. Is there a lightweight way of doing this without downloading the image and comparing it to the local file?
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?
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;
}
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 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]
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.
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!
Does anyone know how to get the size in pixels or scale value of the viewport after a user has pinched or double tapped to zoom in/out on a page in JavaScript?
I've tried using window.innerWidth but I've had mixed results. Sometimes it seems to accurately give the number of pixels the viewport is showing, however, if I zoom way in on a page and then do a large pinch to zoom back out, window.innerWidth will be around 600-700 even though it is only showing ~200px of the page. The page is only 400px wide and it didn't show the checkered "you've gone too far" background you see when you zoom out beyond the page size.
If I do small pinches to zoom in and out, window.innerWidth appears to work just fine. Unfortunately I can't rely on a user only making small pinch gestures :)
I've also tried to use the scale property on the gesture event object, but I've found that unreliable because you don't always know the initial scale when you reload the page or use back/forward buttons to navigate to it even when using the meta tag to specify it.
Ultimately, I'm trying to make an app that is aware of when a user is trying to zoom out beyond the maximum zoom level so if there is another way to do this I'm interested in hearing about it :)
Here's the code I'm using to get the innerWidth:
document.body.addEventListener('gestureend', function (evt) {
console.log(window.innerWidth); // inaccurate when doing large pinch gestures
}, false);
Thanks!
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?
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...
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.
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?