Search Results

Search found 1559 results on 63 pages for 'nslog'.

Page 26/63 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • Why aren't my objects sorting with sortedArrayUsingDescriptors?

    - by clozach
    I expected the code below to return the objects in imageSet as a sorted array. Instead, there's no difference in the ordering before and after. NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"imageID" ascending:YES]; NSSet *imageSet = collection.images; for (CBImage *image in imageSet) { NSLog(@"imageID in Set: %@",image.imageID); } NSArray *imageArray = [[imageSet allObjects] sortedArrayUsingDescriptors:(descriptor, nil)]; [descriptor release]; for (CBImage *image in imageArray) { NSLog(@"imageID in Array: %@",image.imageID); } Fwiw, CBImage is defined in my core data model. I don't know why sorting on managed objects would work any differently than on "regular" objects, but maybe it matters. As proof that @"imageID" should work as the key for the descriptor, here's what the two log loops above output for one of the sets I'm iterating through: 2010-05-05 00:49:52.876 Cover Browser[38678:207] imageID in Array: 360339 2010-05-05 00:49:52.876 Cover Browser[38678:207] imageID in Array: 360337 2010-05-05 00:49:52.877 Cover Browser[38678:207] imageID in Array: 360338 2010-05-05 00:49:52.878 Cover Browser[38678:207] imageID in Array: 360336 2010-05-05 00:49:52.879 Cover Browser[38678:207] imageID in Array: 360335 ... For extra credit, I'd love to get a general solution to troubleshooting NSSortDescriptor troubles (esp. if it also applies to troubleshooting NSPredicate). The functionality of these things seems totally opaque to me and consequently debugging takes forever.

    Read the article

  • Playing wav files with AudioServices in iPhone

    - by Biranchi
    Hi All, I am trying to play two .wav files in my appllication, but i am only able to play the first wav file , the second file is not at all playing. I have added the AudioToolbox framework. In my .h file i have included the Audiotoolbox.h file and has the following declarations //Beep Sound SystemSoundID soundFileObject; SystemSoundID recycleFileObject; In my .m file i am registering both the wav files as following CFURLRef soundFileURLRef = CFBundleCopyResourceURL (CFBundleGetMainBundle (),CFSTR ("Beep"),CFSTR ("wav"),NULL ); AudioServicesCreateSystemSoundID (soundFileURLRef,&soundFileObject ); CFURLRef soundFileURLRef2 = CFBundleCopyResourceURL (CFBundleGetMainBundle (),CFSTR ("Recycle"),CFSTR ("wav"),NULL ); AudioServicesCreateSystemSoundID (soundFileURLRef2,&recycleFileObject ); And i have written two methods for playing each file individually. -(void)playBeepSound { NSLog(@"Beep sound called : %d", soundFileObject); AudioServicesPlaySystemSound (soundFileObject); } -(void)playRecycleSound { NSLog(@"Recycle sound called : %d", recycleFileObject); AudioServicesPlaySystemSound (recycleFileObject); } But i am only able to play the Beep sound , but not the second sound wav file. What is the error ??? Thanks

    Read the article

  • Connection

    - by pepersview
    Hello, I would like to ask you about NSURLConnection in objective-c for iPhone. I have one app that needs to connect to one webservice to receive data (about YouTube videos), Then I have all the things that I need to connect (Similar to Hello_Soap sample code in the web). But now, my problem is that I create a class (inherits from NSObject) named Connection and I have implemented the methods: didReceiveResponse, didReceiveData, didFailWithError and connectionDidFinishLoading. Also the method: -(void)Connect:(NSString *) soapMessage{ NSLog(soapMessage); NSURL *url = [NSURL URLWithString:@"http://....."]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if( theConnection ) { webData = [[NSMutableData data] retain]; } else { NSLog(@"theConnection is NULL"); } } But when from my AppDelegate I create one Connection object: Connection * connect = [[Connection alloc] Init:num]; //It's only one param to test. [connect Connect:method.soapMessage]; And I call this method, when this finishes, it doesn't continue calling didReceiveResponse, didReceiveData, didFailWithError or connectionDidFinishLoading. I'm trying to do this but I can't for the moment. The thing I would like to do is to be able to call this class "Connection" each time that I want to receive data (after that to be parsed and displayed in UITableViews). Thank you.

    Read the article

  • Can't block capslock with CGEventTap

    - by Thor Frølich
    I'm using Quartz CGEventTap in an attempt to globally intercept capslock presses and block them (to have them do something useful instead). I succesfully detect capslock presses but have so far been unable to block them. My code (originating from this stackoverflow answer) is something like this: eventTap = CGEventTapCreate(kCGHIDEventTap, kCGTailAppendEventTap, kCGEventTapOptionDefault, eventMask, myCGEventCallback, &oldFlags); runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0); CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes); CGEventTapEnable(eventTap, true); CGEventRef myCGEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef theEvent, void *refcon) { CGEventFlags *oldFlags = (CGEventFlags *)refcon; switch (type) { case kCGEventFlagsChanged: { CGEventFlags newFlags = CGEventGetFlags(theEvent); CGEventFlags changedFlags = *oldFlags ^ newFlags; *oldFlags = newFlags; if (changedFlags == 65536) { NSLog(@"Capslock pressed. Let's not return the event"); return NULL; } break; } default: break; } NSLog(@"Different modifier than capslock. Returning the event"); return theEvent; } If I understand correctly returning NULL should effectively block the keypress from propagating. Indeed it also does for "normal" keyup and -down events. However capslock toggles regardless. Any ideas why that is? Am I making incorrect assumptions? And/or how can I do things differently to achieve my goal? Thanks, Thor

    Read the article

  • sqlite issues on iphone

    - by prajakta
    i can execute query but i can see the only last value of list_ID i want to access 4 but i am getting 6 ??? list_ID is ----------------------->is 4 2010-12-24 12:57:07.507 DatabaseTest[3398:207] QUERY EXECUTION 2010-12-24 12:57:07.508 DatabaseTest[3398:207] bxbxbxmnb 2010-12-24 12:57:07.508 DatabaseTest[3398:207] list_ID is ----------------------->is 5 2010-12-24 12:57:07.509 DatabaseTest[3398:207] QUERY EXECUTION 2010-12-24 12:57:07.510 DatabaseTest[3398:207] bxbxbxmnb 2010-12-24 12:57:07.511 DatabaseTest[3398:207] list_ID is ----------------------->is 6 this is the code if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) { while(sqlite3_step(compiledStatement) == SQLITE_ROW) { acat=[[[Cat_tableList alloc]init]autorelease]; ///////////// statement//////// NSLog(@" QUERY EXECUTION"); // sStudent.cat_id=[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]; acat.list_id=[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)]; acat.cat_id=[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)]; acat.names=[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]; acat.content=[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)]; [appDelegate.catLists addObject:acat]; (@"final AUTo_ID array is ............%@",acat.content); NSLog(@" list_ID is ----------------------->is %@",acat.list_id); i just want value to b 4 so that i can use this somewhere /////////////// }

    Read the article

  • iPhone: Using a NSMutableArry in the AppDelegate as a Global Variable

    - by aahrens
    What i'm trying to accomplish is to have an NSMutableArray defined in the AppDelegate. I then have two UIViewControllers. One view is responsible for displaying the array from the AppDelegate. The other view is used to add items to the array. So the array starts out to be empty. View1 doesn't display anything because the array is empty. The User goes to View2 and adds an item to the array in AppDelegate. Then when the user goes back to View1 it now displays one item. Here is how I'm trying to accomplish this @interface CalcAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; UITabBarController *tabBarController; NSMutableArray *globalClasses; } @property (nonatomic,retain) NSMutableArray *globalClasses; My other view In the viewDidload I set the array in my View to be the one in the AppDelegate. In an effort to retain values. allCourses = [[NSMutableArray alloc]init]; CalcAppDelegate *appDelegate = (CalcAppDelegate *)[[UIApplication sharedApplication] delegate]; allCourses = appDelegate.globalClasses; Then I would update my allCourses array by adding a new item. Then try to set the array in the AppDelegate to be equal to the modified one. CalcAppDelegate *appDel = (CalcAppDelegate *)[[UIApplication sharedApplication] delegate]; NSLog(@"Size before reset %d",[appDel.globalClasses count]); appDel.globalClasses = allCourses; NSLog(@"Size after reset %d",[appDel.globalClasses count]); What I'm seeing that's returned is 2 in the before, and 2 after. So it doesn't appear to be getting updated properly. Any suggestions?

    Read the article

  • Where'd my sounds go?

    - by Dane Man
    In my Row class I have the initWithCoder method and everything restored in that method works fine, but only within the method. After the method is called I loose an array of sounds that is in my Row class. The sounds class also has the initWithCoder method, and the sound plays fine but only in the Row class initWithCoder method. After decoding the Row object, the sound array disappears completely and is unable to be called. Here's my source for the initWithCoder: - (id) initWithCoder:(NSCoder *)coder { ... soundArray = [coder decodeObjectForKey:@"soundArray"]; NSLog(@"%d",[soundArray count]); return self; } the log shows the count as 8 like it should (this is while unarchiving). Then the row object I create gets assigned. And the resulting row object no longer has a soundArray. [NSKeyedArchiver archiveRootObject:row toFile:@"DefaultRow"]; ... row = [NSKeyedUnarchiver unarchiveObjectWithFile:@"DefaultRow"]; So now whenever I call the soundArray it crashes. //ERROR IS HERE NSLog(@"%d",[[row soundArray] count]); Help please (soundArray is an NSMutableArray).

    Read the article

  • When is Facebook Connect supposed to call its delegate methods?

    - by RickiG
    Hi The Facebook connect code is eluding me a bit. I have no problem doing a login, and a wall post, however, I simply can not figure out how the delegate methods for the FBDialog andFBStreamDialog is supposed to work. - (void)postToWall { FBStreamDialog *dialog = [[[FBStreamDialog alloc] init] autorelease]; dialog.delegate = self; dialog.userMessagePrompt = @"Enter your message:"; dialog.attachment = [NSString stringWithFormat:@"JSONpost code"]; [dialog show]; } I adhere to these protocols in my controller: <FBDialogDelegate, FBSessionDelegate, FBRequestDelegate> I then implement the two methods: - (void) dialogDidCancel:(FBDialog *)dialog { NSLog(@"Failed"); } - (void) dialogDidSucceed:(FBDialog *)dialog { NSLog(@"Success"); } After I tap "publish" and the postToWall methods is done executing the Facebook "pop up" in the UI is empty, except a small "X" in the top right corner and a "F" (facebook logo) in the top left corner. The UI will stay there until I tap the "X", this results in the dialogDidCancel delegate method being called. The post data is showing up on the Facebook page, everything seems to work. Why is thedialogDidSucceedmethod never called? I need this to release my facebook controller and restore the UI back to where the user was before "starting" FB Connect. Thank You:)

    Read the article

  • NSMutableArray Problem - iPhone

    - by David Schiefer
    Hi, I'm trying to get a UITableView to read it's data from a file. I've attempted it like this: NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fullFileName = [NSString stringWithFormat:@"%@/entries.plist", documentsDirectory]; self.dataForTable = [[NSMutableArray alloc] initWithContentsOfFile:fullFileName]; This compiles fine, but when saving something to the file in the following snippet, the file is not saved nor anything is written to the array: NSMutableDictionary*userDictionary; userDictionary = [[NSMutableDictionary alloc] init]; [userDictionary setObject:name.text forKey:@"name"]; [userDictionary setObject:email.text forKey:@"email"]; [userDictionary setObject:serial.text forKey:@"serial"]; [userDictionary setObject:notes.text forKey:@"notes"]; [userDictionary setObject:[NSNumber numberWithInt:[licenseType selectedRowInComponent:0]] forKey:@"license_type"]; [userDictionary setObject:[date date] forKey:@"date"]; [userDictionary setObject:[NSNumber numberWithBool:[paymentSwitch isOn]] forKey:@"payment"]; NSString*dirToSaveTo = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSString*fileName = [NSString stringWithFormat:@"%@.plist",name.text]; NSString*saveName = [dirToSaveTo stringByAppendingPathComponent:fileName]; [userDictionary writeToFile:saveName atomically:NO]; NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fullFileName = [NSString stringWithFormat:@"%@/entries.plist", documentsDirectory]; [self.dataForTable addObject:name.text]; NSLog(@"%@",self.dataForTable); [self.dataForTable writeToFile:fullFileName atomically:YES]; The NSLog just returns (null). The *plist file is never written. What am I doing wrong?

    Read the article

  • Core Data, Bindings, value transformers : crash when saving

    - by Gael
    Hi, I am trying to store a PNG image in a core data store backed by an sqlite database. Since I intend to use this database on an iPhone I can't store NSImage objects directly. I wanted to use bindings and an NSValueTransformer subclass to handle the transcoding from the NSImage (obtained by an Image well on my GUI) to an NSData containing the PNG binary representation of the image. I wrote the following code for the ValueTransformer : + (Class)transformedValueClass { return [NSImage class]; } + (BOOL)allowsReverseTransformation { return YES; } - (id)transformedValue:(id)value { if (value == nil) return nil; return [[[NSImage alloc] initWithData:value] autorelease]; } - (id)reverseTransformedValue:(id)value { if (value == nil) return nil; if(![value isKindOfClass:[NSImage class]]) { NSLog(@"Type mismatch. Expecting NSImage"); } NSBitmapImageRep *bits = [[value representations] objectAtIndex: 0]; NSData *data = [bits representationUsingType:NSPNGFileType properties:nil]; return data; } The model has a transformable property configured with this NSValueTransformer. In Interface Builder a table column and an image well are both bound to this property and both have the proper value transformer name (an image dropped in the image well shows up in the table column). The transformer is registered and called every time an image is added or a row is reloaded (checked with NSLog() calls). The problem arises when I am trying to save the managed objects. The console output shows the error message : [NSImage length]: unrecognized selector sent to instance 0x1004933a0 It seems like core data is using the value transformer to obtain the NSImage back from the NSData and then tries to save the NSImage instead of the NSData. There are probably workarounds such as the one presented in this post but I would really like to understand why my approach is flawn. Thanks in advance for your ideas and explanations.

    Read the article

  • How do I update a progress bar in Cocoa during a long running loop?

    - by Nic
    Hi, I've got a while loop, that runs for many seconds and that's why I want to update a progress bar (NSProgressIndicator) during that process, but it updates only once after the loop has finished. The same happens if I want to update a label text, by the way. I believe, my loop prevents other things of that application to happen. There must be another technique. Does this have to do with threads or something? Am I on the right track? Can someone please give me a simple example, how to “optimize” my application? My application is a Cocoa Application (Xcode 3.2.1) with these two methods in my Example_AppDelegate.m: // This method runs when a start button is clicked. - (IBAction)startIt:(id)sender { [progressbar setDoubleValue:0.0]; [progressbar startAnimation:sender]; running = YES; // this is a instance variable int i = 0; while (running) { if (i++ = processAmount) { // processAmount is something like 1000000 running = NO; continue; } // Update progress bar double progr = (double)i / (double)processAmount; NSLog(@"progr: %f", progr); // Logs values between 0.0 and 1.0 [progressbar setDoubleValue:progr]; [progressbar needsDisplay]; // Do I need this? // Do some more hard work here... } } // This method runs when a stop button is clicked, but as long // as -startIt is busy, a click on the stop button does nothing. - (IBAction)stopIt:(id)sender { NSLog(@"Stop it!"); running = NO; [progressbar stopAnimation:sender]; } I'm really new to Objective-C, Cocoa and applications with a UI. Thank you very much for any helpful answer.

    Read the article

  • Update a tableView with a plist took from another table

    - by Pheel
    Background: I have a tab bar application, which has a tableView as the "heart" of the app. It loads data from a plist and, through a button that checks if there are any updates on the remote plist file, updates the local plist with the remote contents. Then, i have another tableView, that should display only those plist items that have a bool value set to YES. Now i want to add a button to the second table that reloads the plist took from the first table. Expected: When i update the local plist from the first table and when i press the button on the second table, the 2nd table is supposed to update and show the cells with that bool value set to YES. (Note: I set YES as default to some items on plist). What happens: The first table updates its content from remote. The second table shows the old items with the value set to YES. When i press the button to refresh data, it reads the plist fine (by logging it, it has the same contents of the first table -only those set to YES-),but it doesn't update data even if i have [self.tableView reloadData];. When i close the app and open it again, the second table is filled with the right items. :\ Code i'm using: //Reading Plist { NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *plistPath = [[documentPaths lastObject] stringByAppendingPathComponent:@"myPlist.plist"]; NSFileManager *fMgr = [NSFileManager defaultManager]; if (![fMgr fileExistsAtPath:plistPath]) { plistPath = [[NSBundle mainBundle] pathForResource:@"myPlist" ofType:@"plist"]; } NSMutableArray *returnArr = [NSMutableArray arrayWithContentsOfFile:plistPath]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"isFav == YES"]; for (NSDictionary *sect in returnArr) { NSArray *arr = [sect objectForKey:@"Rows"]; [sect setValue:[arr filteredArrayUsingPredicate:predicate] forKey:@"Rows"]; } [self.tableView reloadData]; } //Refresh data button - (void) refreshTable:(id)sender { NSLog(@"plist read"); [self readPlist]; NSLog(@"refreshed plist:%@",[self readPlist]); [self.tableView reloadData]; } Does anyone know why the table is not updating?

    Read the article

  • How to move a symlink to the trash?

    - by neoneye
    I don't see any options for the FSPathMoveObjectToTrashSync() function for not following links. Here is what I have tried Create a link and a file [ 21:32:41 /tmp ] $ touch my_file [ 21:32:45 /tmp ] $ ln -s my_file my_link [ 21:32:52 /tmp ] $ la total 8 drwxrwxrwt 12 root wheel 408 17 Maj 21:32 . drwxr-xr-x@ 6 root wheel 204 9 Sep 2009 .. -rw-r--r-- 1 neoneye wheel 0 17 Maj 21:32 my_file lrwxr-xr-x 1 neoneye wheel 7 17 Maj 21:32 my_link -> my_file Move the link to the trash OSStatus status = FSPathMoveObjectToTrashSync( "/tmp/my_link", NULL, kFSFileOperationDefaultOptions ); NSLog(@"status: %i", (int)status); Output is status: 0 However the file got removed and not the link [ 21:32:55 /tmp ] $ la total 8 drwxrwxrwt 11 root wheel 374 17 Maj 21:33 . drwxr-xr-x@ 6 root wheel 204 9 Sep 2009 .. lrwxr-xr-x 1 neoneye wheel 7 17 Maj 21:32 my_link -> my_file [ 21:33:05 /tmp ] $ How can I move move symlinks to the trash? The Solution.. thanks to Rob Napier NSString* path = @"/tmp/my_link"; OSStatus status = 0; FSRef ref; status = FSPathMakeRefWithOptions( (const UInt8 *)[path fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &ref, NULL ); NSAssert((status == 0), @"failed to make FSRef"); status = FSMoveObjectToTrashSync( &ref, NULL, kFSFileOperationDefaultOptions ); NSLog(@"status: %i", (int)status);

    Read the article

  • HTML entity encoding (convert '<' to '&lt;') on iPhone in objective-c

    - by Markus
    I'm developing an application for the iPhone that has inApp-mail sending capabilities. So far so good, but now I want to avoid html-injections as some parts of the mail are user-generated texts. Basically I search for something like this: // inits NSString *sourceString = [NSString stringWithString:@"Hello world! Grüße dich Welt <-- This is in German."]; // ----- THAT'S WHAT I'M LOOKING FOR // pseudo-code | // V NSString *htmlEncodedString = [sourceString htmlEncode]; // log NSLog(@"source string: %@", sourceString); NSLog(@"encoded string: %@", htmlEncodedString); Expected output source string: Hello world! Grüße dich Welt <-- This is in German. encoded string: Hello world! Gr&#252;&#223;e dich Welt &lt;-- This is in German. I already googled and looked through several of SO's questions and answers, but all of them seem to be related to URL-encoding and that's not what I really need (I tried stringByAddingPercentEscapesUsingEncoding with no luck - it creates %C3%BC out of an 'ü' that should be an ü). A code sample would be really great (correcting mine?)... -- Thanks in advance, Markus

    Read the article

  • MKAnnotations are being made successfully, however they sometimes fail to render on MKMapView

    - by jtkendall
    I'm working on an iPhone app using the 3.1.3 SDK, my app finds the users current location, displays it on a MKMapView and then finds nearby locations and renders them as MKAnnotations. My code is working, however sometimes the nearby annotations do not appear on the map. They are still being made as I see the correct data in the console (from NSLog which runs just after the annotations are made). When it fails is completely random, it could be the 5th time I've hit "Build and Run" for the day, or the 500th it doesn't appear to have any pattern and doesn't throw any type of error, it just doesn't add the annotations to the MapView. This is the method called for each nearby location to add the MKAnnotation. - (void)addPinsWithLocation:(NSDictionary *)spot { CLLocationCoordinate2D location; location.longitude = [[spot objectForKey:@"spot_longitude"] doubleValue]; location.latitude = [[spot objectForKey:@"spot_latitude"] doubleValue]; PlaceMarks *placemark = [[PlaceMarks alloc] initWithCoordinate:location title:[spot objectForKey:@"spot_name"] subtitle:@""]; NSLog(@"Adding Pin for Location: '%@' at %f, %f", [spot objectForKey:@"spot_name"], location.latitude, location.longitude); [mapView addAnnotation:placemark]; } Any ideas on how to get MKAnnotations to always show?

    Read the article

  • http-post request for a long String in iOS

    - by onkar
    I am looking to send a very long String, which is an image that is encoded into a String. I need to send that information using POST method. I have implemented the same in Android using key-value pair, I need to implement the same in iOS using key-value pair. Please help me with useful resources/approach. EDIT 1 What have I tried [dictionnary setObject:@"admin" forKey:@"username"]; [dictionnary setObject:@"123123" forKey:@"password"]; NSError *error = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionnary options:kNilOptions error:&error]; NSString *urlString = @"MY CALL URL"; NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:jsonData]; NSURLResponse *response = NULL; NSError *requestError = NULL; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&requestError]; NSLog(@"response is obtained"); NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] ; NSLog(@"%@", responseString); EDIT 2 Error I am getting Request Error Error Domain=kCFErrorDomainCFNetwork Code=303 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 303.)" UserInfo=0x7ba0120 {NSErrorFailingURLKey=http://yahoo.com/, NSErrorFailingURLStringKey=http://yahoo.com/}

    Read the article

  • Using Quartz to draw every second via NSTimer (iPhone)

    - by stuartloxton
    Hi, I'm relatively new to Objective-C + Quartz and am running into what is probably a very simple issue. I have a custom UIView sub class which I am using to draw simple rectangles via Quartz. However I am trying to hook up an NSTimer so that it draws a new object every second, the below code will draw the first rectangle but will never draw again. The function is being called (the NSLog is run) but nothing is draw. Code: - (void)drawRect:(CGRect)rect { context = UIGraphicsGetCurrentContext(); [self step:self]; [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)(2) target:self selector:@selector(step:) userInfo:nil repeats:TRUE]; } - (void) step:(id) sender { static double trans = 0.5f; CGContextSetRGBFillColor(context, 1, 0, 0, trans); CGContextAddRect(context, CGRectMake(10, 10, 10, 10)); CGContextFillPath(context); NSLog(@"Trans: %f", trans); trans += 0.01; } context is in my interface file as: CGContextRef context; Any help will be greatly appreciated!

    Read the article

  • compiler directive defensive programming for adding ints to nsmuatablearray FMDB/EGODB

    - by johndpope
    I would like to throw a warning message when users try to add an int to an nsmutablearray basically any insert statement that includes values that are not nsstring / nsnumber cause run time crashes. It's exactly the same crash you get when you type %@ instead of %d NSLog(int); The crash is ok, but I want to throw a friendly 'FATAL' message to user. so far I have this try catch with isKindOfClass NSObject but ints are slipping through. #define FATAL_MSG "FATAL: object is not an NSObject subclass. Are you using int? use [NSNumber numberWithInt:1] \n" #define VAToArray(firstarg) ({\ NSMutableArray* valistArray = [NSMutableArray array];\ id obj = nil;\ va_list arguments;\ va_start(arguments, sql);\ @try { \ while ((obj = va_arg(arguments, id))) {\ if([obj isKindOfClass:[NSObject class]]) [valistArray addObject:obj];\ else printf(FATAL_MSG); \ }\ } \ @catch(NSException *exception){ \ printf(FATAL_MSG); \ } \ va_end(arguments);\ valistArray;\ }) - (void)test:(NSString*)sql,... { NSLog(@"VAToArray :%@",VAToArray(sql)); } // then call this [self test:@"str",@"test",nil]; when I call this [self test:@"str",2,nil]; throw the error message.

    Read the article

  • strange run time error message from CIImage initWithContentsOfURL

    - by Adam
    When executing the following code I receive a run time error when the code executes the second line of code. The error (which shows up in the debugger) says: [NSButton initWithContentsOfURL:]: unrecognized selector sent to instance 0x100418e10. I don't understand this message, because it looks to me (based on my source code) like the initWithContentsOfURL message is being sent to the myImage instance (of the CIImage class) ... not NSButton. Any idea what is going on? If it matters ... this code is in the Application Controller class module of an Xcode project (a Cocoa application) -- within a method that is called when I click on a button on the application window. There is only the one button on the window ... // Step1: Load the JPG file into CIImage NSURL *myURL = [NSURL fileURLWithPath:@"/Users/Adam/Documents/Images/image7.jpg"]; CIImage *myImage = [myImage initWithContentsOfURL: myURL]; if (myImage = Nil) { NSLog(@"Creating myImage failed"); return; } else { NSLog(@"Created myImage successfully"); }

    Read the article

  • iphone NSMutableArray loses objects at end of method

    - by Brodie4598
    Hello - in my app, an NSMutableArray is populated with an object in viewDidLoad (eventually there will be many objects but I'm just doing one til I get it working right). I also start a timer that starts a method that needs to access the NSMutableArray every few seconds. The NSMutableArray works fine in viewDidLoad, but as soon as that method is finished, it loses the object. myApp.h @interface MyApp : UIViewController { NSMutableArray *myMutableArray; NSTimer *timer; } @property (nonatomic, retain) NSMutableArray *myMutableArray; @property (nonatomic, retain) NSTimer *timer; @end myApp.m #import "MyApp.h" @implementation MyApp @synthesize myMutableArray; - (void) viewDidLoad { cycleTimer = [NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(newCycle) userInfo: nil repeats:YES]; MyObject *myCustomUIViewObject = [[MyObject alloc]init]; [myMutableArray addObject:myCustomUIViewObject]; [myCustomUIViewObject release]; NSLog(@"%i",[myMutableArray count]); /////outputs "1" } -(void) newCycle { NSLog(@"%i",[myMutableArray count]); /////outputs "0" ?? why is this?? }

    Read the article

  • How to upload image to remote server in iphone?

    - by Atulkumar V. Jain
    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...

    Read the article

  • Core Data confusion: fetch without tableview.

    - by Mr. McPepperNuts
    I have completed and reproduced Core Data tutorials using a tableview to display contents. However, I want to access an Entity through a fetch on a view without a tableview. I used the following fetch code, but the count returned is always 0. The data exists when the database is opened using SQLite tools. NSManagedObject *entryObj; XYZDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; NSManagedObjectContext *managedObjectContext = appDelegate.managedObjectContext; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Quote" inManagedObjectContext:managedObjectContext]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"id" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; [request setEntity: entity]; NSArray *results = [managedObjectContext executeFetchRequest:request error:nil]; if (results == nil) { NSLog(@"No results found"); entryObj = nil; }else { NSLog(@"results %d", [results count]); } [request release]; [sortDescriptors release]; count returned is always 0; it should be 5. Can anyone point me to a reference or tutorial regarding creating a controller not to be used with a tableview.

    Read the article

  • How to add objects to NSArray from a different class with ARC

    - by Space Dust
    I needed to convert my code to ARC. I have an NSArray that I use to draw a path. I fill the objects of NSArray values from a different class. Problem is after converting to ARC, NSArray returns always null I can not see what I am doing wrong. bug.h @interface Ladybug : CCSprite <CCTargetedTouchDelegate>{ CCArray *linePathPosition; } @property (nonatomic, strong) CCArray *linePathPosition; @end bug.m @synthesize linePathPosition; -(id) init { if( (self=[super init] )) { self.linePathPosition = [[CCArray alloc] init]; } return self; } -(void) updatePosition:(CGPoint) position { [self.linePathPosition addObject:[NSValue valueWithCGPoint:position]]; NSLog(@"line path %@",linePathPosition); } -(void) breakMoveLadyBug { [self.linePathPosition removeAllObjects]; } In main .m - (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event { Ladybug *ladybug1 = (Ladybug *)[self getChildByTag:99]; CCMotionStreak* streak = (CCMotionStreak *)[self getChildByTag:999]; CGPoint touchLocation = [touch locationInView: [touch view]]; CGPoint curPosition = [[CCDirector sharedDirector] convertToGL:touchLocation]; if (ladybug1.isSelected) { streak.position = curPosition; [ladybug1 updatePosition:curPosition]; NSLog(@"Cur position %@",NSStringFromCGPoint(curPosition)); if (!ladybug1.isMoving) { [ladybug1 startMoveLadyBug]; } } } Log: Cur position {331, 110} line path (null) What am I doing wrong? What is the proper way to define and init NSArray with ARC?

    Read the article

  • NSURLConnection receives data even if no data was thrown back

    - by Anna Fortuna
    Let me explain my situation. Currently, I am experimenting long-polling using NSURLConnection. I found this and I decided to try it. What I do is send a request to the server with a timeout interval of 300 secs. (or 5 mins.) Here is a code snippet: NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageAllowedInMemoryOnly timeoutInterval:300]; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&resp error:&err]; Now I want to test if the connection will "hold" the request if no data was thrown back from the server, so what I did was this: if (data != nil) [self performSelectorOnMainThread:@selector(dataReceived:) withObject:data waitUntilDone:YES]; And the function dataReceived: looks like this: - (void)dataReceived:(NSData *)data { NSLog(@"DATA RECEIVED!"); NSString *string = [NSString stringWithUTF8String:[data bytes]]; NSLog(@"THE DATA: %@", string); } Server-side, I created a function that will return a data once it fits the arguments and returns none if nothing fits. Here is a snippet of the PHP function: function retrieveMessages($vardata) { if (!empty($vardata)) { $result = check_data($vardata) //check_data is the function which returns 1 if $vardata //fits the arguments, and 0 if it fails to fit if ($result == 1) { $jsonArray = array('Data' => $vardata); echo json_encode($jsonArray); } } } As you can see, the function will only return data if the $result is equal to 1. However, even if the function returns nothing, NSURLConnection will still perform the function dataReceived: meaning the NSURLConnection still receives data, albeit an empty one. So can anyone help me here? How will I perform long-polling using NSURLConnection? Basically, I want to maintain the connection as long as no data is returned. So how will I do it? NOTE: I am new to PHP, so if my code is wrong, please point it out so I can correct it.

    Read the article

  • Migrating from a single entity to an abstract parent entity with child entities, NSEntityMigrationPolicy not called.

    - by Jimmy Selgen Nielsen
    Hi. I'm trying to upgrade my current application to use an abstract parent entity, with specialized sub entities. I've created a custom NSEntityMigrationPolicy, and in the mapping model I've set the Custom Policy to the name of my class. I'm initializing my persistent store like this, which should be fairly standard : NSError *error=nil; persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]]; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, nil]; if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) { NSLog(@"Error adding persistent store : %@",[error description]); NSAssert(error==nil,[error localizedDescription]); } When i run the app i get the following error : Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The operation couldn’t be completed. (Cocoa error 134140.)' [error userInfo] contains "reason=Can't find mapping model for migration" I've verified that version 1 of the data model will open, and if i set NSInferMappingModelAutomaticallyOption i get a migration, although my entities are not migrated correctly (as expected). I've verified that the mapping model (cdm) is in the application bundle, but somehow it refuses to find it. I've also set breakpoints and NSLog() statements in the custom migration policy, and none of it runs, with or without NSInferMappingModelAutomaticallyOption Any hints as to why it seems unable to find the mapping model ?

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >