Search Results

Search found 12101 results on 485 pages for 'objective c runtime'.

Page 14/485 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Writing to a new line of a file in Objective-C

    - by Kulpreet
    For some strange reason, the \n and \r escape sequences do not seem to be working in my code. I want to write each NSString on a new line of the file, but it just appends it the last string on one line. Here's the code: for (Entry *entry in self.entries) { NSString *path = @"/Users/me/File.txt"; NSString *string = (@"%@\r\n", [entry thisEntry]); NSFileHandle *fh = [NSFileHandle fileHandleForWritingAtPath:path]; [fh seekToEndOfFile]; [fh writeData:[string dataUsingEncoding:NSUnicodeStringEncoding]]; [fh closeFile]; } Am I doing something wrong? Forgive me as I am new to Objective-C.

    Read the article

  • Why do Programmers Love/Hate Objective-C?

    - by Genericrich
    So I have noticed that there is a lot of animosity towards Objective-C among programmers. What's your take? Is it a vendor lock-in thing against Apple? General antipathy towards Apple? The syntax? What's your view on this? With the advent of the iPhone SDK, Obj-C has gotten a lot more attention lately, and I am curious what people on SO's opinions are. I personally fought the syntax at first but have gotten more and more used to it now. I really like the named arguments. I have some pet peeves with how things are done in Obj-C vs other languages, but I will refrain from comment on them here.

    Read the article

  • When should you NOT use the asterisk (*) when declaring a variable in Objective C

    - by Jason
    I have just started learning objective c and the asterisk is giving me some trouble. As I look through sample code, sometime it is used when declaring a variable and sometimes it is not. What are the "rules" for when it should be used. I thought it had something to do with the data type of the variable. (asterisk needed for object data types, not needed for simple data types like int) However, I have seen object data types such as CGPoint declared without the asterisk as well? Is there a definitive answer or does it have to do with how and what you use the variable for?

    Read the article

  • objective-c EXC_BAD_ACCESS in my code...

    - by Mark
    I'm new to objective-c and Im trying to write a little sample app that gets some XML from a remote server and outputs it to the console, but when I do it I get a EXC_BAD_ACCESS which I dont understand: NSString *FeedURL = @"MYURLGOESHERE"; NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:FeedURL]]; NSURLResponse *resp = nil; NSError *err = nil; NSData *response = [NSURLConnection sendSynchronousRequest: theRequest returningResponse: &resp error: &err]; NSString *theString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]; NSLog(@"Response: %@", theString);]; [resp release]; [err release]; When I comment out the [resp release] line I dont get it anymore, can someone please explain this to me :) Thanks

    Read the article

  • Objective C block gives link error

    - by ennuikiller
    I'm trying to use objective-c blocks for some iPhone programming and am getting the following link time error: The relevant code is: - (NSDictionary *) getDistances { CLLocationCoordinate2D parkingSpace; NSMutableDictionary *dict; NSIndexSet *indexForUser; BOOL (^test)(id obj, NSUInteger idx, BOOL *stop); test = ^ (id obj, NSUInteger idx, BOOL *stop) { NSString *user = (NSString *)[(NSDictionary *)obj valueForKey:@"userid"]; if ([user isEqualToString:self->sharedUser.userName]) { return YES; } return NO; }; [self->sharedUser.availableParking indexesOfObjectsPassingTest:test]; } Any help would be very much appreciated!!

    Read the article

  • Newbie Objective C developer question

    - by R.J.
    I have been looking everywhere for an answer to this question - perhaps I'm looking in the wrong places. Also, I'm brand new to Objective C although I have around 10 years of experience as a developer. for this code: [receiver makeGroup:group, memberOne, memberTwo, memberThree]; what would the method definition look like? - (void)makeGroup:(Group *)g, (NSString *)memberOne, ...? Thanks for any help you can provide. I know this is probably very simple... Thanks, R

    Read the article

  • How to implement SCORM in Objective C

    - by iranjan
    Hey, Do you know how to implement SCORM (Sharable Content Object Reference Model) in Objective C for eLearning content? Let me explain you what exactly I am looking for. I have one MCQ (multiple choice question) application which has 4 questions. On attempting each question I want my application to interact with a SCORM compatible server with result (whether the user has attempted correct one or not). The communication channel should be to and fro. May be at the end of the MCQ I want to show result which will come from the server with some calculations*(like Score : 85% number of attempts : 16 average score:16.7% etc.)*. How should I go about it? Please guide if you have already achieved it regards Ranjan.

    Read the article

  • referencing an instantiated object in another class in objective C

    - by Paul
    hi, I am working in xcode on an ipod app in objective C, and I have a field (navigationController) in one of my classes (rootViewController). How do I reference the instantiated rootViewController's navigationController from another class? For example, how would I do this if I want to reference the navigationController from the FirstViewController.m class? I seem to only be able to find references for this to reference the application delegate. If I want to reference the application delegate with FirstViewController, I just say: MyAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.navigationController pushViewController:childController animated:YES]; how do I do this for the rootViewController class instead of MyAppDelegate?

    Read the article

  • Call javascript from objective-c, only works with system functions like alert() etc / phonegap

    - by adrian
    hi havent found the solution yet in the forum. i want to call a function i created in the index.html via a objective-c function. As explained in stringByEvaluatingJavaScriptFromString so the network detection doesnt work for me the function gets called but no javascript is called in the index.html here is the code i use - (void)updateReachability:(NSString*)callback { NSString* jsCallback = @"navigator.network.updateReachability"; if (callback) jsCallback = callback; NSString* status = [[NSString alloc] initWithFormat:@"%@({ hostName: '%@', ipAddress: '%@', remoteHostStatus: %d, internetConnectionStatus: %d, localWiFiConnectionStatus: %d });", jsCallback, [[Reachability sharedReachability] hostName], [[Reachability sharedReachability] address], [[Reachability sharedReachability] remoteHostStatus], [[Reachability sharedReachability] internetConnectionStatus], [[Reachability sharedReachability] localWiFiConnectionStatus]]; [webView stringByEvaluatingJavaScriptFromString:status]; [status release]; } If i log the status the string i see can be executed in the index.html file, the syntax is ok. but it doesnt get called if i do alert( etc... it gets called... need some help pls, because network detection is a kill criteria to publish a app!!! Adrian

    Read the article

  • What's wrong with my Objective-C class?

    - by zgillis
    I am having trouble with my Objective-C code. I am trying to print out all of the details of my object created from my "Person" class, but the first and last names are not coming through in the NSLog method. They are replaced by spaces. Person.h: http://pastebin.com/mzWurkUL Person.m: http://pastebin.com/JNSi39aw This is my main source file: #import <Foundation/Foundation.h> #import "Person.h" int main (int argc, const char * argv[]) { Person *bobby = [[Person alloc] init]; [bobby setFirstName:@"Bobby"]; [bobby setLastName:@"Flay"]; [bobby setAge:34]; [bobby setWeight:169]; NSLog(@"%s %s is %d years old and weighs %d pounds.", [bobby first_name], [bobby last_name], [bobby age], [bobby weight]); return 0; }

    Read the article

  • Applying the same function to each object of an array in objective-c

    - by sagar
    Hey ! every one. I am having some query regarding Objective-c. Let's have a look to following code. NSArray *ar=[scrPDFPage subviews]; int i; for (i=0; i<[ar count]; i++) { [(UIView*)[ar objectAtIndex:i] removeFromSuperview]; } now my queries are as follows, Instead of rotating a loop, isn't there an option like, [ar applyFunctionToObjects:@selector(myFunction:)] Isn't there any option like [myView removeAllSubViews]; ( According to my knowledge, there is no option like remove all sub views, but in case you might know. ) Thanks in advance for sharing your knowledge. Sagar.

    Read the article

  • HOM with Objective C

    - by Coxer
    Hey, i am new to objective C, but i tried to use HOM in order to iterate over an NSArray and append a string to each element. here is my code: void print( NSArray *array ) { NSEnumerator *enumerator = [array objectEnumerator]; id obj; while ( nil!=(obj = [enumerator nextObject]) ) { printf( "%s\n", [[obj description] cString] ); } } int main( int argc, const char *argv[] ) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *names = [[NSArray alloc] init]; NSArray *names_concat = [[NSArray alloc] init]; names = [NSArray arrayWithObjects:@"John",@"Mary",@"Bob",nil]; names_concat = [[names collect] stringByAppendingString: @" Doe"]; print(names_concat); [pool release]; } What is wrong with this code? My compiler (gcc) says NSArray may not respond to "-collect"

    Read the article

  • Objective-C assigning variables question for iphone.

    - by coder net
    The following piece of code can be written in two ways. I would like to know what are the pros and cons of each. If possible I would like to stick with the one liner. 1) UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Background.png"]]; self.view.backgroundColor = background; [background release]; 2) self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Background.png"]]; Any issues with releasing memory etc. with #2? I'm new to Objective-C and would like to follow the best approach.

    Read the article

  • Editing Mac OS X login items in Objective-C through AppleScript

    - by mon4goos
    In my Cocoa program, I want to examine what programs are registered to run at startup and modify that list as I feel appropriate. In order to be compatible with Tiger it seems like I need to work through AppleScript. I currently have the following code: NSDictionary* errorDict; NSAppleEventDescriptor* returnDescriptor = NULL; NSString *appleSource = @"tell application \"System Events\"\n\ get every login item\n\ end tell"; NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource: appleSource]; returnDescriptor = [appleScript executeAndReturnError: &errorDict]; If I run that command in AppleScript, I get back an array of login items. However, I can't figure out how to iterate through this array in Objective-C. More specifically, I want to examine the names and paths of the programs registered to run at startup. Any ideas?

    Read the article

  • Using a REST API and iPhone/Objective-C

    - by Neil Desai
    So I'm brand new to Netflix's API and have never used an API ever before. I'm ok with Objective-C and Cocoa Touch but just have no clue where to start when accessing the API and how to in general. Can someone help me get started with some code that will access titles in Netflix or just how to access a REST API in general with authentication. Thanks. Update: I've looked at the documents and I'm still a little lost because the Netflix API is a little weird with OAuth. Any help?

    Read the article

  • Objective-C partial implementation of classes in separate files

    - by Aran Mulholland
    I am using core data and am generating classes from my data model. I implement custom methods in these classes, however when i regenerate i generate over the top so i end up copying and pasting a bit. What i would like to do is split my implementation files ('.m') so i can have one header file with multiple '.m' files. then i can keep my custom methods in one and not have to worry about erasing them when i regenerate. I use this technique in .NET a lot with its partial keyword. Is there anything similar in objective-C

    Read the article

  • Objective-C: How to create a method that will return a UInt8 array from an int

    - by Adam
    I need to create an Objective-C method that converts an int into a byte array. In this instance, I can't use NSArray as a return type, it must be an UInt8 array. I've written a simple method to do this, but it has errors during compile and tells me that I have incompatible return types. Here is the code snippet. Any ideas? - (UInt8[])ConvertToBytes:(int) i { UInt8 *retVal[4]; retVal[0] = i >> 24; retVal[1] = i >> 16; retVal[2] = i >> 8; retVal[3] = i >> 0; return retVal; }

    Read the article

  • Objective-C : Trouble with file download

    - by Holli
    I ran in a bit of trouble downloading files with Objective-C. I use the download decideDestinationWithSuggestedFilename from Apples documentation page. http://developer.apple.com/mac/library/documentation/cocoa/conceptual/URLLoadingSystem/Tasks/UsingNSURLDownload.html As long as I want to download just one file it works fine but I want to download an array for files one by one. The problem starts with the second file. Right now my code will trigger the next download itself from the downloadDidFinish Method. Then I will get an unrecognized selector sent to instance error. For me it looks like the NSURLDownload that just finished the download is still in use somehow. Release is called but the must be a problem. If I just put an NSBeep in the downloadDidFinished Method and trigger the next file download manually it works fine. Looks like I have to wait a while till I can start the next download. I know this question is a bit vague but maybe someone got an idea.

    Read the article

  • Load a file in a group objective-c Xcode

    - by okami
    I'd like to load a file from a specific Group in Xcode/Objective-c for example: I have TWO files named "SomeFile.txt" that are in two different folders (folders not groups yet) in the OS: SomeFolderOne |- SomeFile.txt SomeFolderTwo |- SomeFile.txt Inner Xcode I make two folders, and I put a REFERENCE to these two files: SomeGroupOne |- SomeFile.txt // this file is a reference to the SomeFile.txt from SomeFolderOne SomeGroupTwo |- SomeFile.txt // this file is a reference to the SomeFile.txt from SomeFolderTwo Now I want to read the txt content with: NSString *contents = [NSString stringWithContentsOfFile:@"SomeFile.tx" encoding:NSUTF8StringEncoding error:nil]; Ok it reads the 'SomeFile.txt' but sometimes the file read is from SomeGroupOne and sometimes the file is read from SomeGroupTwo. How to specify the group I want the file to be read?

    Read the article

  • Trouble using opaque pointers in Objective C++

    - by morgancodes
    The answer to this quesion explains that opaque pointers are a good way to include C++ member variables in an Objective C++ header. I'm getting compile errors when trying to follow the example. Here's the relevant code from my header, with the corresponding compiler errors shown as comments: struct ADSR_opaque; // error: forward declaration of 'struct ADSR_opaque' @interface LoopyPulser : NSObject{ float _pulseRate; UInt32 tickInterval; UInt32 step; InMemoryAudioFile * audioFilePlayer; ADSR_opaque* env; // error: expected specifier-qualifier-list before 'ADSR_opaque' Pattern * pattern; float loopLengthRatio; float volume; } Is there something simple I'm doing wrong here?

    Read the article

  • Create a template mechanism in Objective-C for iPad applications

    - by Flex_Addicted
    I'm looking for a solution to create a sort of template in Objective C. I'll try to explain my problem. I would create a sort of main view which has 1 side bar that remain always visible. This side bar have controls. The main view is responsible to load a Navigation Controller (UINavigationController seems to be ok) that manages other views. When switching a view to another, the sidebar always remain visible under the Navigation Controller and its views. Through the controls of the sidebar, it's possible to send event to a specific view loaded by the Navigation Controller. Any idea to create a similar template? Thank you. Best regards.

    Read the article

  • Using malloc/free in Objective-C object

    - by Itamar Katz
    I have a class AudioManager with a member of type AudioBufferList *. (This is a struct declared in the CoreAudio framework). Since AudioBufferList is not a NSObject, I cannot retain it, so I have to alloc/free it (correct me if I'm wrong). My question is, where is the 'right' place to free it? Currently I am doing it in the dealloc method of AudioManager. If I understand correctly, this method is invoked automatically once the release message is sent to the instance of AudioManager --- is that true? Is there any other recommended practice regarding using alloc/free on non-objects members of Objective-C objects? Edit: From Apples documentation: Subclasses must implement their own versions of dealloc to allow the release of any additional memory consumed by the object—such as dynamically allocated storage for data or object instance variables owned by the deallocated object. After performing the class-specific deallocation, the subclass method should incorporate superclass versions of dealloc through a message to super: Which makes things a little bit clearer - but more insights are appreciated.

    Read the article

  • differing methods of alloc / init / retaining an object in objective-c

    - by taber
    In several pieces of sample objective-c code I've seen people create new objects like this: RootViewController *viewController = [[RootViewController alloc] init]; self.rootViewController = viewController; // self.rootViewController is a (nonatomic,retain) synthesized property [viewController release]; [window addSubview: [self.rootViewController view]]; Is that any different "behind the scenes" than doing it like this instead? self.rootViewController = [[RootViewController alloc] init]; [window addSubview: [self.rootViewController view]]; Seems a bit more straightforward/streamlined that way so I'm wondering why anyone would opt for the first method. Thanks!

    Read the article

  • Objective-C getter/ setter question

    - by pic-o-matic
    Hi, im trying to works my way trough an Objective-C tutorial. In the book there is this example: @interface { int width; int height; XYPoint *origin; } @property int width, height; I though, hey there's no getter/setter for the XYPoint object. The code does work though. Now i'm going maybe to answer my own question :). I thinks its because "origin" is a pointer already, and whats happening under the hood with "width" and "height", is that there is going te be created a pointer to them.. Am i right, or am i talking BS :) ??

    Read the article

  • Can somebody explain this Objective C method declaration syntax

    - by Doug R
    I'm working through an iPhone development book* without really knowing Objective C. For the most part I'm able to follow what's going on, but there are a few method declarations like the one below that I'm having a bit of trouble parsing. For example: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section { return [self.controllers count]; //controllers is an instance variable of type NSArray in this class } It looks this is a method called numberOfRowsInSection, and it returns an NSInteger, and takes an NSInteger as a parameter which is locally called 'section'. But I don't understand all the references to tableView, or why this takes a parameter when it is not used within the method. Can somebody clarify this? Thanks. *p. 258, Beginning iPhone 3 Development, by Mark and LaMarche, published by Apress

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >