Search Results

Search found 1009 results on 41 pages for 'nsarray'.

Page 10/41 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • want to fetch the friends list of facebook thorough fbconnect in iphone using objective-c ?

    - by uttam
    how to fetch the friends list of facebook in iphone through fbconnect in objective-c? I am using this code (void)getUserName { NSString *fql = [NSString localizedStringWithFormat: @"SELECT uid FROM user WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = %lld)",[FBSession session].uid]; NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"]; [[FBRequest requestWithDelegate:self] call:@"facebook.friends.get" params:params]; } - (void)request:(FBRequest*)request didLoad:(id)result { if ([request.method isEqualToString:@"facebook.fql.query"]) { NSArray* users = result; NSDictionary* user = [users objectAtIndex:0]; NSString* name = [user objectForKey:@"name"]; _label.text = [NSString stringWithFormat:@"Logged in as %@", name]; } else if ([request.method isEqualToString:@"facebook.users.setStatus"]) { NSString* success = result; if ([success isEqualToString:@"1"]) { _label.text = [NSString stringWithFormat:@"Status successfully set"]; } else { _label.text = [NSString stringWithFormat:@"Problem setting status"]; } } else if ([request.method isEqualToString:@"facebook.freinds.get"]) { if(myList==nil) { NSArray* users = result; myList =[[NSArray alloc] initWithArray: users]; for(NSInteger i=0;i<[users count];i++) { NSDictionary* user = [users objectAtIndex:i]; NSString* uid = [user objectForKey:@"uid"]; NSString* fql = [NSString stringWithFormat: @"select name from user where uid == %@", uid]; NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"]; [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params]; } } else { NSArray* users = result; NSDictionary* user = [users objectAtIndex:0]; NSString* name = [user objectForKey:@"name"]; //txtView.text=[NSString localizedStringWithFormat:@"%@%@,\n",txtView.text,name]; NSLog(name); }} I want to get the friends list from facebook and then search/modify then add it to my addressbook. I know this code is doing this but I don't know how to use it or where do I use it.. If you could please post something or just elaborate on how do I use your code thru fbconnect framework. I have implemented upto get permissions and publish feeds one's wall. But please can you post here about the layout details of the results, like what do Ineed to use on the layout point of view.

    Read the article

  • NSKeyedUnarchiver chokes when trying to unarchive more than one object

    - by ajduff574
    We've got a custom matrix class, and we're attempting to archive and unarchive an NSArray containing four of them. The first seems to get unarchived fine (we can see that initWithCoder is called once), but then the program simply hangs, using 100% CPU. It doesn't continue or output any errors. These are the relevant methods from the matrix class (rows, columns, and matrix are our only instance variables): -(void)encodeWithCoder:(NSCoder*) coder { float temp[rows * columns]; for(int i = 0; i < rows; i++) { for(int j = 0; j < columns; j++) { temp[columns * i + j] = matrix[i][j]; } } [coder encodeBytes:(const void *)temp length:rows*columns*sizeof(float) forKey:@"matrix"]; [coder encodeInteger:rows forKey:@"rows"]; [coder encodeInteger:columns forKey:@"columns"]; } -(id)initWithCoder:(NSCoder *) coder { if (self = [super init]) { rows = [coder decodeIntegerForKey:@"rows"]; columns = [coder decodeIntegerForKey:@"columns"]; NSUInteger * len; *len = (unsigned int)(rows * columns * sizeof(float)); float * temp = (float * )[coder decodeBytesForKey:@"matrix" returnedLength:len]; matrix = (float ** )calloc(rows, sizeof(float*)); for (int i = 0; i < rows; i++) { matrix[i] = (float*)calloc(columns, sizeof(float)); } for(int i = 0; i < rows *columns; i++) { matrix[i / columns][i % columns] = temp[i]; } } return self; } And this is really all we're trying to do: NSArray * weightMatrices = [NSArray arrayWithObjects:w1,w2,w3,w4,nil]; [NSKeyedArchiver archiveRootObject:weightMatrices toFile:@"weights.archive"]; NSArray * newWeights = [NSKeyedUnarchiver unarchiveObjectWithFile:@"weights.archive"]; What's driving us crazy is that we can archive and unarchive a single matrix just fine. We've done so (successfully) with a matrix many times larger than these four combined.

    Read the article

  • iphone download help thanks

    - by Floo
    hi all !  i create an array using :  NSURL *url = [NSURL URLWithString:@"http;//www.myadress.myplist.plist"];f NSArray *tmp = [NSArray arrayWithContentsOfURL:url]; how do i know when the download is complete ?  thanks to all !

    Read the article

  • MKMap showing detail of annotations

    - by yeohchan
    I have encountered a problem of populating the description for each annotation. Each annotation works, but there is somehow an area when trying to click on it. Here is the code. the one in bold is the one that has the problem. -(void)viewDidLoad{ FlickrFetcher *fetcher=[FlickrFetcher sharedInstance]; NSArray *rec=[fetcher recentGeoTaggedPhotos]; for(NSDictionary *dic in rec){ NSLog(@"%@",dic); NSDictionary *string = [fetcher locationForPhotoID:[dic objectForKey:@"id"]]; double latitude = [[string objectForKey:@"latitude"] doubleValue]; double longitude = [[string objectForKey:@"longitude"]doubleValue]; if(latitude !=0 && latitude != 0 ){ CLLocationCoordinate2D coordinate1 = { latitude,longitude }; **NSDictionary *adress=[NSDictionary dictionaryWithObjectsAndKeys:[dic objectForKey:@"owner"],[dic objectForKey:@"title"],nil];** MKPlacemark *anArea=[[MKPlacemark alloc]initWithCoordinate:coordinate1 addressDictionary:adress]; [mapView addAnnotation:anArea]; } } } Here is what the Flickr class does: #import <Foundation/Foundation.h> #define TEST_HIGH_NETWORK_LATENCY 0 typedef enum { FlickrFetcherPhotoFormatSquare, FlickrFetcherPhotoFormatLarge } FlickrFetcherPhotoFormat; @interface FlickrFetcher : NSObject { NSManagedObjectModel *managedObjectModel; NSManagedObjectContext *managedObjectContext; NSPersistentStoreCoordinator *persistentStoreCoordinator; } // Returns the 'singleton' instance of this class + (id)sharedInstance; // // Local Database Access // // Checks to see if any database exists on disk - (BOOL)databaseExists; // Returns the NSManagedObjectContext for inserting and fetching objects into the store - (NSManagedObjectContext *)managedObjectContext; // Returns an array of objects already in the database for the given Entity Name and Predicate - (NSArray *)fetchManagedObjectsForEntity:(NSString*)entityName withPredicate:(NSPredicate*)predicate; // Returns an NSFetchedResultsController for a given Entity Name and Predicate - (NSFetchedResultsController *)fetchedResultsControllerForEntity:(NSString*)entityName withPredicate:(NSPredicate*)predicate; // // Flickr API access // NOTE: these are blocking methods that wrap the Flickr API and wait on the results of a network request // // Returns an array of Flickr photo information for photos with the given tag - (NSArray *)photosForUser:(NSString *)username; // Returns an array of the most recent geo-tagged photos - (NSArray *)recentGeoTaggedPhotos; // Returns a dictionary of user info for a given user ID. individual photos contain a user ID keyed as "owner" - (NSString *)usernameForUserID:(NSString *)userID; // Returns the photo for a given server, id and secret - (NSData *)dataForPhotoID:(NSString *)photoID fromFarm:(NSString *)farm onServer:(NSString *)server withSecret:(NSString *)secret inFormat:(FlickrFetcherPhotoFormat)format; // Returns a dictionary containing the latitue and longitude where the photo was taken (among other information) - (NSDictionary *)locationForPhotoID:(NSString *)photoID; @end

    Read the article

  • Detect same images name {iPhone SDK}

    - by Momeks
    hi , i want create image animation , i have 50 images with png format now i want set images name ... something like this but doesnt work ! my images name are : iamge_0000 to image_0050 NSArray *myImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"image_%d.png"], //image named doesnt work ??!?!?!?

    Read the article

  • Copy NSAttributedString to pasteboard

    - by Chris
    Brand new to Cocoa and I'm trying to figure out how to copy an NSAttributedString to the pasteboard. I've looked in the docs and not sure if I'm supposed to use a NSPasteboardItem or not. Here's what I have to copy a regular NSString: NSPasteboard *pb = [NSPasteboard generalPasteboard]; NSArray *types = [NSArray arrayWithObjects:NSStringPboardType, nil]; [pb declareTypes:types owner:self]; [pb setString:@"asdfasdf" forType:NSStringPboardType]; How do I set a NSAttributedString? Thanks

    Read the article

  • Can lazy loading be considered an example of RAII?

    - by codemonkey
    I have been catching up on my c++ lately, after a couple years of exclusive Objective-C on iOS, and the topic that comes up most on 'new style' c++ is RAII To make sure I understand RAII concept correctly, would you consider Objective-C lazy loading property accessors a type of RAII? For example, check the following access method - (NSArray *)items { if(_items==nil) { _items=[[NSArray alloc] initWithCapacity:10]; } return _items } Would this be considered an example of RAII? If not, can you please explain where I'm mistaken?

    Read the article

  • Set UIImageView Size?

    - by Tronic
    hi, i have following problem: i generate subviews UIView in an UIScrollView including UIImageViews. NSArray *bilder = [[NSArray alloc] initWithObjects:@"lol.jpg", @"lol2.jpg", nil]; NSArray *added = [[NSMutableArray alloc] init]; UIImageView *tmpView; for (NSString *name in bilder) { UIImage *image = [UIImage imageNamed:name]; tmpView = [[UIImageView alloc] initWithImage:image]; tmpView.contentMode = UIViewContentModeScaleAspectFit; tmpView.frame = CGRectMake(0, 0, 300, 300); [added addObject:tmpView]; [tmpView release]; } CGSize framy = mainFrame.frame.size; NSUInteger x = 0; for (UIView *view in added) { [mainFrame addSubview:view]; view.frame = CGRectMake(framy.height * x++, 0, framy.height, framy.width); } mainFrame.scrollEnabled = YES; mainFrame.pagingEnabled = YES; mainFrame.contentSize = CGSizeMake(framy.height * [added count], framy.width); mainFrame.backgroundColor = [UIColor blackColor]; i get image file names out of an array. now i want to resize the imageview to a specific size, but it won't work. any advice? thanks + regards

    Read the article

  • NSTextField autocomplete

    - by Rasmus Styrk
    Does anyone know of any class or lib that can implement autocompletion to an NSTextField? I'am trying to get the standard autocmpletion to work but it is made as a synchronous api. I get my autocompletion words via an api call over the internet. What have i done so far is: - (void)controlTextDidChange:(NSNotification *)obj { if([obj object] == self.searchField) { [self.spinner startAnimation:nil]; [self.wordcompletionStore completeString:self.searchField.stringValue]; if(self.doingAutocomplete) return; else { self.doingAutocomplete = YES; [[[obj userInfo] objectForKey:@"NSFieldEditor"] complete:nil]; } } } When my store is done, i have a delegate that gets called: - (void) completionStore:(WordcompletionStore *)store didFinishWithWords:(NSArray *)arrayOfWords { [self.spinner stopAnimation:nil]; self.completions = arrayOfWords; self.doingAutocomplete = NO; } The code that returns the completion list to the nstextfield is: - (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index { *index = -1; return self.completions; } My problem is that this will always be 1 request behind and the completion list only shows on every 2nd char the user inputs. I have tried searching google and SO like a mad man but i cant seem to find any solutions.. Any help is much appreciated.

    Read the article

  • Variable Scope Problem, iPhone

    - by Stumf
    Hello all, I need some help here so I will do my best to explain. I have worked on this all day and had no success (just learning!) I have: NSArray *getValue(NSString *iosearch) { ................................. ................................... \\ More code here } - (NSString *) serialnumber { NSArray *results = getValue(@"serial-number"); if (results) return [results objectAtIndex:0]; return nil; } - (NSString *) backlightlevel { NSArray *results = getValue(@"backlight-level"); if (results) return [results objectAtIndex:0]; return nil; } I have a tableView set up and want to display my array in it so I then have: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {............. ......................................................... cell.text = [results objectAtIndex:indexPath.row]; // error results undeclared here return cell; } The problem is I get results undeclared as indicated above. I also can't figure how I could get serialnumber and backlightlevel to display on the click of a button or even at load. My attempts have thrown back errors like error: 'serialnumber' undeclared (first use in this function) and warnings like warning: 'return' with a value, in function returning void. Sorry for the long question! Many thanks, Stuart

    Read the article

  • Is This a Valid Way to Use Blocks in Objective-C?

    - by Carter
    I've been building a HTTP client that uses web services to synchronize information between the client and server. I've been using Blocks and NSURLConnection to achieve this on the client side, but I'm getting frequent EXC_BAD_ACCESS crashes in objc_msgSend(). From what I understand, this usually means that a stored block that has fallen off the stack has been called. I think I've coded things correctly to avoid this, but I'm still stuck. Here is conceptually what my code is doing. It starts by calling "synchronizeWithWebServer". That method invokes "listRootObjectsOnServerWithBlock:" which takes in a block to be called when the method returns. "listRootObjectsOnServersWithBlock:" initiates a NSURLConnection to the web server asynchronously. It to expects a block to be called when it returns. Inside that block I want to be able to execute the original Block (so aptly named 'block'). This is only a simplified version of my code. The real synchronization process is more complex but it's mostly more of the same as what you see below. Sometimes the code works perfectly, but about 80% of the time it crashes very early on in the routine. It seems to be more vulnerable to crashing when my data set gets larger. - (void)synchronizeWithWebServer { [self listRootObjectsOnServerWithBlock:^(NSArray *results, NSError *error) { //Iterate over result objects and perform some other similar routines. }]; } - (void)listRootObjectsOnServerWithBlock:(void (^)(NSArray *results, NSError *error))block { //Create NSURLRequest Here //Create connection asynchronously. block = [block copy]; [NSURLConnection sendAsynchronousRequest:urlRequest queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error){ //Parse response from web server (stored in NSData *data) NSArray *results = ..... //Call 'block' block(results, error); [block release]; }]; }

    Read the article

  • [CFArray release]: message sent to deallocated instance

    - by arielcamus
    Hi, I'm using the following method in my code: - (NSMutableArray *) newOrderedArray:(NSMutableArray *)array ByKey:(NSString *)key ascending:(BOOL)ascending { NSSortDescriptor *idDescriptor = [[NSSortDescriptor alloc] initWithKey:key ascending:ascending]; NSArray *sortDescriptors = [NSArray arrayWithObject:idDescriptor]; NSArray *orderArray = [array sortedArrayUsingDescriptors:sortDescriptors]; [idDescriptor release]; NSMutableArray *result = [NSMutableArray arrayWithArray:orderArray]; return result; } Is this a well-coded convenience method? As I think, it returns an autoreleased NSMutableArray. This method is called by another one: - (id) otherMethod { NSMutableArray *otherResult = [[[NSMutableArray alloc] initWithCapacity:[otherArray count]] autorelease]; // I add some stuff to otherResult and then... NSMutableArray *result = [dbUtils newOrderedArray:otherResult ByKey:@"objectId" ascending:NO]; return result; } This method (otherMethod) is called in some view controller where I want to store returned array and release it when deallocating the view controller. However, when [result retain] is called in this view controller (because I need it to be available and I can't allow it to be deallocated) I receive the following error: [CFArray release]: message sent to deallocated instance I've tried to log [result retainCount] just before calling retain and it print "1". I don't understand why an error is thrown when calling retain. Thank you, A

    Read the article

  • Simple CalendarStore query puts application into infinite loop!?

    - by Frank R.
    Hi, I've been looking at adding iCal support to my new application and everything seemed just fine and worked on my Mac OS X 10.6 Snow Leopard development machine without a hitch. Now it looks like depending on what is in your calendar the very simple query below: - (NSArray*) fetchCalendarEventsForNext50Minutes { NSLog(@"fetchCalendarEventsForNext50Minutes"); NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; NSDate* startDate = [[NSDate alloc] init]; NSDate* endDate = [startDate addTimeInterval: 50.0 * 60.0]; NSPredicate *eventsForTheNext50Minutes = [CalCalendarStore eventPredicateWithStartDate:startDate endDate:endDate calendars:[[CalCalendarStore defaultCalendarStore] calendars]]; // Fetch all events for this year NSArray *events = [[CalCalendarStore defaultCalendarStore] eventsWithPredicate: eventsForTheNext50Minutes]; NSLog( @"fetch took: %f seconds", [NSDate timeIntervalSinceReferenceDate] - start ); return events; } produces a beachball thrash even with quite limited events in the calendar store. Am I missing something crucial here? The code snippet is pretty much exactly from the documentation at: // Create a predicate to fetch all events for this year NSInteger year = [[NSCalendarDate date] yearOfCommonEra]; NSDate *startDate = [[NSCalendarDate dateWithYear:year month:1 day:1 hour:0 minute:0 second:0 timeZone:nil] retain]; NSDate *endDate = [[NSCalendarDate dateWithYear:year month:12 day:31 hour:23 minute:59 second:59 timeZone:nil] retain]; NSPredicate *eventsForThisYear = [CalCalendarStore eventPredicateWithStartDate:startDate endDate:endDate calendars:[[CalCalendarStore defaultCalendarStore] calendars]]; // Fetch all events for this year NSArray *events = [[CalCalendarStore defaultCalendarStore] eventsWithPredicate:eventsForThisYear]; It looks like it has something to do with the recurrence rules, but as far as I can see there are no other ways of fetching events from the calendar store anyway. Has anybody else come across this? Best regards, Frank

    Read the article

  • Loading UITableView form UIView

    - by Amarpreet
    Hi Guys, I am working on navigation based application in which i can navigate to many views starting from default UITableView which is starting view in application template. I have added another UIView and added tableView control on that UIView. I am calling that view form one of the many views on a button click. Its showing the view but not populating the data in the table. And I also want to handle the event when user taps on the cell of the table of that view. Below is the Code I am using on button click: if(self.lstView == nil) { ListViewController *viewController = [[ListViewController alloc] initWithNibName:@"ListViewController" bundle:nil]; self.lstView = viewController; [viewController release]; } [self.navigationController pushViewController:lstView animated:YES]; self.lstView.title = @"Select";//@"System"; [self.lstView.tblList.dataSource fillList]; Below is the fillList function code: -(NSArray *)fillList { NSArray *tempArray = [[[NSArray alloc] initWithObjects:@"Item 1" , @"Item 2" , nil]autorelease]; return tempArray; } I am pretty new in Iphone programming and don't have much understanding. Helping with detailed description and code will be highly appreciated. Thanks.

    Read the article

  • Looking for advice on importing large dataset in sqlite and Cocoa/Objective-C

    - by jluckyiv
    I have a fairly large hierarchical dataset I'm importing. The total size of the database after import is about 270MB in sqlite. My current method works, but I know I'm hogging memory as I do it. For instance, if I run with Zombies, my system freezes up (although it will execute just fine if I don't use that Instrument). I was hoping for some algorithm advice. I have three hierarchical tables comprising about 400,000 records. The highest level has about 30 records, the next has about 20,000, the last has the balance. Right now, I'm using nested for loops to import. I know I'm creating an unreasonably large object graph, but I'm also looking to serialize to JSON or XML because I want to break up the records into downloadable chunks for the end user to import a la carte. I have the code written to do the serialization, but I'm wondering if I can serialize the object graph if I only have pieces in memory. Here's pseudocode showing the basic process for sqlite import. I left out the unnecessary detail. [database open]; [database beginTransaction]; NSArray *firstLevels = [[FirstLevel fetchFromURL:url retain]; for (FirstLevel *firstLevel in firstLevels) { [firstLevel save]; int id1 = [firstLevel primaryKey]; NSArray *secondLevels = [[SecondLevel fetchFromURL:url] retain]; for (SecondLevel *secondLevel in secondLevels) { [secondLevel saveWithForeignKey:id1]; int id2 = [secondLevel primaryKey]; NSArray *thirdLevels = [[ThirdLevel fetchFromURL:url] retain]; for (ThirdLevel *thirdLevel in thirdLevels) { [thirdLevel saveWithForeignKey:id2]; } [database commit]; [database beginTransaction]; [thirdLevels release]; } [secondLevels release]; } [database commit]; [database release]; [firstLevels release];

    Read the article

  • Core data setReturnsDistinctResult not working

    - by Moze
    So i'm building a small application, it uses core data database of ~25mb size with 4 entities. It's for bus timetables. In one table named "Stop" there are have ~1300 entries of bus stops with atributes "name", "id", "longitude", "latitude" and couple relationships. Now there are many stops with same name but different coordinates and id. Search is implemented using NSPredicate. So I want to show all distinct stop names in table view, i'm using setReturnsDistinctResults with NSDictionaryResultType and setPropertiesToFetch. But setReturnsDistinctResult is not working and I'm still getting all entries. Heres code: - (NSFetchRequest *)fetchRequest { if (fetchRequest == nil) { fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Stop" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; NSArray *sortDescriptors = [NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES] autorelease]]; [fetchRequest setSortDescriptors:sortDescriptors]; [fetchRequest setResultType:NSDictionaryResultType]; [fetchRequest setPropertiesToFetch:[NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"name"]]]; [fetchRequest setReturnsDistinctResults:YES]; DebugLog(@"fetchRequest initialized"); } return fetchRequest; } ///////////////////// - (NSFetchedResultsController *)fetchedResultsController { if (self.predicateString != nil) { self.predicate = [NSPredicate predicateWithFormat:@"name CONTAINS[cd] %@", self.predicateString]; [self.fetchRequest setPredicate:predicate]; } else { self.predicate = nil; [self.fetchRequest setPredicate:predicate]; } fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:self.fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:sectionNameKeyPath cacheName:nil]; return fetchedResultsController; } ////////////// - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = [[fetchedResultsController objectAtIndexPath:indexPath] valueForKey:@"name"]; return cell; }

    Read the article

  • Pass Result of ASIHTTPRequest "requestFinished" Back to Originating Method

    - by Intelekshual
    I have a method (getAllTeams:) that initiates an HTTP request using the ASIHTTPRequest library. NSURL *httpURL = [[[NSURL alloc] initWithString:@"/api/teams" relativeToURL:webServiceURL] autorelease]; ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:httpURL] autorelease]; [request setDelegate:self]; [request startAsynchronous]; What I'd like to be able to do is call [WebService getAllTeams] and have it return the results in an NSArray. At the moment, getAllTeams doesn't return anything because the HTTP response is evaluated in the requestFinished: method. Ideally I'd want to be able to call [WebService getAllTeams], wait for the response, and dump it into an NSArray. I don't want to create properties because this is disposable class (meaning it doesn't store any values, just retrieves values), and multiple methods are going to be using the same requestFinished (all of them returning an array). I've read up a bit on delegates, and NSNotifications, but I'm not sure if either of them are the best approach. I found this snippet about implementing callbacks by passing a selector as a parameter, but it didn't pan out (since requestFinished fires independently). Any suggestions? I'd appreciate even just to be pointed in the right direction. NSArray *teams = [[WebService alloc] getAllTeams]; (currently doesn't work, because getAllTeams doesn't return anything, but requestFinished does. I want to get the result of requestFinished and pass it back to getAllTeams:)

    Read the article

  • Subclassing NSArrayController in order to limit size of arrangedObjects

    - by Simone Manganelli
    I'm trying to limit the number of objects in an array controller, but I still want to be able to access the full array, if necessary. A simple solution I came up with was to subclass NSArrayController, and define a new method named "limitedArrangedObjects", that returns a limited number of objects from the real set of arranged objects. (I've seen http://stackoverflow.com/questions/694493/limiting-the-number-of-objects-in-nsarraycontroller , but that doesn't address my problem.) I want this property to be observable via bindings, so I set a dependency to arrangedObjects on it. Problem is, when arrangedObjects is updated, limitedArrangedObjects seems not to be observing the value change in arrangedObjects. I've hooked up an NSCollectionView to limitedArrangedObjects, and zero objects are being displayed. (If I bind it to arrangedObjects instead, all the objects show up as expected.) What's the problem? Here's the relevant code: @property (readonly) NSArray *limitedArrangedObjects; - (NSArray *)limitedArrangedObjects; { NSArray *arrangedObjects = [super arrangedObjects]; NSUInteger upperLimit = 10000; NSUInteger count = [arrangedObjects count]; if (count > upperLimit) count = upperLimit; arrayToReturn = [arrangedObjects subarrayWithRange:NSMakeRange(0, count)]; return arrayToReturn; } + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key; { NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key]; if ([key isEqualToString:@"limitedArrangedObjects"]) { NSSet *affectingKeys = [NSSet setWithObjects:@"arrangedObjects",nil]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKeys]; } return keyPaths; }

    Read the article

  • iPhone OS: Get a list of methods and variables from anonymous object

    - by ChrisOPeterson
    I am building my first iPhone/Obj-c app and I have a large amount of data-holding subclasses that I am passing into a cite function. To the cite function these objects are anonymous and I need to find a way to access all the variables of each passed object. I have been using a pre-built NSArray and Selectors to do this but with more than 30 entries (and growing) it is kind of silly to do manually. There has to be a way to dynamically look up all the variables of an anonymous object. The obj-c runtime run-time docs mention this problem but from what I can tell this is not available in iPhone OS. If it is then I don't understand the implementation and need some guidance. A similar question was asked before but again I think they were talking about OSX and not iPhone. Any thoughts? -(NSString*)cite:(id)source { NSString *sourceClass = NSStringFromClass([source class]); // Runs through all the variables in the manually built methodList for(id method in methodList) { SEL x = NSSelectorFromString(method); // further implementation // Should be something like NSArray *methodList = [[NSArray alloc] initWithObjects:[source getVariableList]] for(id method in methodList) { SEL x = NSSelectorFromString(method); // Further implementation }

    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

  • zoomfactor value in CGAffineTransformMakeScale in iPhone

    - by suse
    Hello, 1) I'm doing pinch zoom on the UIImageView , how should i decide upon the zoomfactor value, because when the zoomfactor value goes beyond 0[i.e negative value]the image is gettig tilted, which i dont want it to happen. how to avoid this situation. 2) Y is the flickring kind of rotationis happening, Y not the smooth rotation? ll this be taken care by CGAffineTransformMakeScale(zoomfactor,zoomfactor);method? This is what i'm doing in my code: zoomFactor = 0;// Initially zoomfactor is set to zero - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@" Inside touchesBegan .................."); NSArray *twoTouches = [touches allObjects]; UITouch *first = [twoTouches objectAtIndex:0]; OPERATION = [self identifyOperation:touches :first]; NSLog(@"OPERATION : %d",OPERATION); if(OPERATION == OPERATION_PINCH){ //double touch pinch UITouch *second = [twoTouches objectAtIndex:1]; f_G_initialDistance = distanceBetweenPoints([first locationInView:self.view],[second locationInView:self.view]); } NSLog(@" leaving touchesBegan .................."); } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@" Inside touchesMoved ................."); NSArray *twoTouchPoints = [touches allObjects]; if(OPERATION == OPERATION_PINCH){ CGFloat currentDistance = distanceBetweenPoints([[twoTouchPoints objectAtIndex:0] locationInView:self.view],[[twoTouchPoints objectAtIndex:1] locationInView:self.view]); int pinchOperation = [self identifyPinchOperation:f_G_initialDistance :currentDistance]; G_zoomFactor = [self calculateZoomFactor:pinchOperation :G_zoomFactor]; [uiImageView_G_obj setTransform:CGAffineTransformMakeScale(G_zoomFactor, G_zoomFactor)]; [self.view bringSubviewToFront:resetButton]; [self.view bringSubviewToFront:uiSlider_G_obj]; f_G_initialDistance = currentDistance; } NSLog(@" leaving touchesMoved .................."); } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@" Inside touchesEnded .................."); NSArray *twoTouches = [touches allObjects]; UITouch *first = [twoTouches objectAtIndex:0]; if(OPERATION == OPERATION_PINCH){ //do nothing } NSLog(@" Leaving touchesEnded .................."); } Thank You.

    Read the article

  • Fetch Data using predicate. Retrieve single value.

    - by Mr. McPepperNuts
    XYZAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; NSManagedObjectContext *managedObjectContext = appDelegate.managedObjectContext; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name == %@", entryToSearchFor]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Entry" inManagedObjectContext:managedObjectContext]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; [request setEntity: entity]; [request setPredicate: predicate]; NSArray *results = [managedObjectContext executeFetchRequest:request error:nil]; if (results == nil) { NSLog(@"No results found"); }else { NSLog(@"entryToSearchFor %@", entryToSearchFor); NSLog(@"results %@", [results objectAtIndex:0]); } I want to retrieve a single value (String) from "Entry." I believe I must be missing. Can someone point it out? Btw, the NSLog results outputs the following: results <NSManagedObject: 0x3d2d360> (entity: Entry; id: 0x3d13650 <x-coredata://6EA12ADA-8C0B-477F-801C-B44FE6E6C91C/Entry/p3> ; data: <fault>)

    Read the article

  • My UITableView has duplicated rows

    - by Mark
    Im not sure why, but my UITableView, which isnt anything fancy, is showing repeating rows when it shouldnt be. It seems that the rows that get added when the user scrolls (i.e. the rows that are off the screen to start with) are getting the data for the wrong row index. Its almost like when a new cell is de-queued, it's using a cell that 'was' used, but wasn't cleaned up correctly. Do you need to 'clean up' cells that are de-queue so that new cells dont use cells that are already created? my code is as below: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CustomCellIdentifier = @"CustomCellIdentifier"; MyDayCell *cell = (MyDayCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MyDayCell" owner:self options:nil]; for (id oneObject in nib) if ([oneObject isKindOfClass:[MyDayCell class]]) cell = (MyDayCell *)oneObject; } NSUInteger section = [indexPath section]; NSUInteger row = [indexPath row]; NSArray *thisSectionItems = (NSArray*)[self.listData objectForKey: [[NSNumber alloc] initWithInt:section]]; MyDayDetails *rowData = [thisSectionItems objectAtIndex:row]; //setup my cells data here... return cell; } Is there anything wrong with this code? has anyone seen anything like this before?

    Read the article

  • iOS Cell Label link

    - by hart1994
    Hi I am new to iOS programming and I need a little help. I have a table view cell which is populated by data from a .plist file. I need to be able to make a link within one of the cells. How could I do this? Here is the code which is loading the data into the cells: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"CustomTableCell"; static NSString *CellNib = @"DetailViewCell"; DetailViewCell *cell = (DetailViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellNib owner:self options:nil]; cell = (DetailViewCell *)[nib objectAtIndex:0]; } cell.accessoryType = UITableViewCellAccessoryNone; cell.cellTitleLabel.textColor = [UIColor blackColor]; cell.cellTitleLabel.font = [UIFont systemFontOfSize:20.0]; cell.cellSubtitleLabel.textColor = [UIColor darkGrayColor]; informations = [[NSArray alloc] initWithObjects:@"City", @"Country", @"State", @"History", @"Link", nil]; subtitles = [[NSArray alloc] initWithObjects:titleString, subtitleString, stateString, populationString, @"Link", nil]; cell.cellTitleLabel.text = [informations objectAtIndex:indexPath.row]; cell.cellSubtitleLabel.text = [subtitles objectAtIndex:indexPath.row]; return (DetailViewCell *) cell; } For the cell "Link" I need it to open a url which is stored in the .plist file. How could i do this? Many thanks Ryan PS: I'm a newbie at this stuff, so be descriptive. Thanks

    Read the article

  • ios UITableView reloadData don't increase content height

    - by Zoltan Varadi
    I'm facing a strange error in my iOS app and haven't been able to figure out the reason why. In my UITableView i can add new cells, so i refresh the array that is the datasource and call reloadData. Everything works without error. The numberOfRowsInSection is called again, and it's value is one more than it's previous value was. The new cell even gets inserted at the bottom of the tableview, but i cant scroll down to it. I only know that it's there because the tableview bounces and i can see it. I'm guessing the tableview's content height is not getting increased for some reason, but i have no idea why. I'm using iOS 6 btw. Any help is very much appreciated! Thanks, Zoli EDIT, answers for Srikanth's questions: How is data getting added. There's an NSArray containing objects of a specific type. The array.count is the number of the number of cells. This NSArray gets its values from a database query. When you say, you are refreshing the array, what do you mean. By refreshing the array i mean i execute a new query in the database and put the results of this query into an NSArray. this will be the tableview's datasource array. Like this: dataSourceArray = [dbManager executeQuery]; [tableView reloadData]; Are you adding the data within the same view controller Yes. Can you show some code as to what you are doing See above. Is the table view at the root of the view controllers view or is it within another view The tableview is the main view's first child. Can you try adding data to the array at the beginning, so that you can view the cell being added at the top. I don't understand what you mean.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >