Search Results

Search found 6745 results on 270 pages for 'objective c 2 0'.

Page 24/270 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • objective C convert NSString to unsigned

    - by user1501354
    I have changed my question. I want to convert an NSString to an unsigned int. Why? Because I want to do parallel payment in PayPal. Below I have given my coding in which I want to convert the NSString to an unsigned int. My query is: //optional, set shippingEnabled to TRUE if you want to display shipping //options to the user, default: TRUE [PayPal getPayPalInst].shippingEnabled = TRUE; //optional, set dynamicAmountUpdateEnabled to TRUE if you want to compute //shipping and tax based on the user's address choice, default: FALSE [PayPal getPayPalInst].dynamicAmountUpdateEnabled = TRUE; //optional, choose who pays the fee, default: FEEPAYER_EACHRECEIVER [PayPal getPayPalInst].feePayer = FEEPAYER_EACHRECEIVER; //for a payment with multiple recipients, use a PayPalAdvancedPayment object PayPalAdvancedPayment *payment = [[PayPalAdvancedPayment alloc] init]; payment.paymentCurrency = @"USD"; // A payment note applied to all recipients. payment.memo = @"A Note applied to all recipients"; //receiverPaymentDetails is a list of PPReceiverPaymentDetails objects payment.receiverPaymentDetails = [NSMutableArray array]; NSArray *emailArray = [NSArray arrayWithObjects:@"[email protected]",@"[email protected]", nil]; for (int i = 1; i <= 2; i++) { PayPalReceiverPaymentDetails *details = [[PayPalReceiverPaymentDetails alloc] init]; // Customize the payment notes for one of the three recipient. if (i == 2) { details.description = [NSString stringWithFormat:@"Component %d", i]; } details.recipient = [NSString stringWithFormat:@"%@",[emailArray objectAtIndex:i-1]]; unsigned order; if (i==1) { order = [[feeArray objectAtIndex:0] unsignedIntValue]; } if (i==2) { order = [[amountArray objectAtIndex:0] unsignedIntValue]; } //subtotal of all items for this recipient, without tax and shipping details.subTotal = [NSDecimalNumber decimalNumberWithMantissa:order exponent:-4 isNegative:FALSE]; //invoiceData is a PayPalInvoiceData object which contains tax, shipping, and a list of PayPalInvoiceItem objects details.invoiceData = [[PayPalInvoiceData alloc] init]; //invoiceItems is a list of PayPalInvoiceItem objects //NOTE: sum of totalPrice for all items must equal details.subTotal //NOTE: example only shows a single item, but you can have more than one details.invoiceData.invoiceItems = [NSMutableArray array]; PayPalInvoiceItem *item = [[PayPalInvoiceItem alloc] init]; item.totalPrice = details.subTotal; [details.invoiceData.invoiceItems addObject:item]; [payment.receiverPaymentDetails addObject:details]; } [[PayPal getPayPalInst] advancedCheckoutWithPayment:payment]; Can anybody tell me how to do this conversion? Thanks and regards in advance.

    Read the article

  • Objective C map view delegate viewForAnnotation for MKAnnotation gets just called after click

    - by user1185486
    I have a simple Map view. It has a method -(void)loadAndDisplayPois{ NSLog(@"loadAndDisplayPois"); if(mapView.annotations.count > 0) [mapView removeAnnotations:mapView.annotations]; self.pois = [self loadPoisFromDatabase]; NSLog(@"self.pois.count: %i", self.pois.count); [mapView addAnnotations:self.pois]; NSLog(@"mapView.annotations.count: %i",mapView.annotations.count);} This method gets called, and I am sure that the method gets called because of the Log, after I downloaded data and saved it into the database. The class which handles the download executes after saving the data to the database [self.senderObj performSelector:@selector(loadAndDisplayPois)]; Where senderObj is the MapViewControlller. The count Log from the pois array shows 4 after the first time I clicked. But no Annotations on the view, because viewForAnnotation is not called (one Annotation in the array ( my current position)). After I execute the method again by clicking a TEST button shows everything on the map. The viewForAnnotation method gets called after viewWillAppear and after I clicked the TEST button. It is driving me nuts since 2 days. I cant anymore ...

    Read the article

  • Translate this code to objective-c iPhone?

    - by Silent
    Hi there would somone know how to translate this cose into iphone programming it seems like its an http message the data i would be sending is audio data im not sure which type of file. Any things helps thanks. /////////////////////////////////////////////////////////// Using the cgi command fifo.cgi will enable the IP camera to start receiving audio data User can use Microsoft WinHTTP C/C++ API to upload the audio file   http://msdn.microsoft.com/en-us/library/aa384252%28v=VS.85%29.aspx   1. Establish connection     hSession = WinHttpOpen(L"WinHTTP Example/1.0",WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,WINHTTP_NO_PROXY_NAME,WINHTTP_NO_PROXY_BYPASS, 0 );        if(hSession)      {          USES_CONVERSION;          hConnect = WinHttpConnect(hSession,A2W(m_cAddr), m_iPort,0);      }   2. Establish listen request        if(hConnect)          hRequest = WinHttpOpenRequest(hConnect,L"POST",L"/cgi-bin/fifo.cgi",NULL,WINHTTP_NO_REFERER,WINHTTP_DEFAULT_ACCEPT_TYPES,0);        if(hRequest)          bResults = WinHttpSendRequest(hRequest,WINHTTP_NO_ADDITIONAL_HEADERS,0,WINHTTP_NO_REQUEST_DATA,0,uDataLength,0);   Send audio data        if( hRequest)          WinHttpWriteData(hRequest, pData, nDataSize, &dwBytesWritten); //////////////////////////////////////////////////////////////////////////

    Read the article

  • Determining Screen Positions in Objective-C (NSScreen)

    - by Peter Zich
    Using [NSScreen screens] I'm able to get all of the screens attached to the computer and their sizes, however I'm trying to find out their positions relative to each other (like in Arrangement in the Display preferences). Is there a way to do this? I've looked online and through the class references on Apple's developer site and found nothing. Thank you.

    Read the article

  • Memory management technique for Objective-C iVars/properties

    - by David Rea
    Is the following code doing anything unnecessary? @interface MyClass { NSArray *myArray; } -(void)replaceArray:(NSArray *)newArray; @implementation MyClass -(void)replaceArray:(NSArray *)newArray { if( myArray ) { [myArray release]; myArray = nil; } myArray = [[NSArray alloc] initWithArray: newArray]; } @end What if I made the following changes: 1) Made myArray a property: @property (nonatomic, retain) NSArray myArray; 2) Changed the assignment to: self.myArray = [NSArray arrayWithArray: newArray]; Would that allow me to remove the conditional?

    Read the article

  • if string is alphabetically greater than other string in objective

    - by Jonathan
    I'm trying to use an if statement to work out which of 2 strings comes first alphabetically. Like with numbers and greater and less than: if (1 < 2) { just with strings: if(@"ahello" < @"bhello") { Or would I have to have a string containing all the letters and then check the index of the first char in each string and see which index is greater, and the index that is less than the other comes first in the alphabet and then if they are equal move on to the next char and repeat?

    Read the article

  • How to modify XML on Objective-C?

    - by Vic
    Hi, I'm working on a project for the iPad, I need to read and write to an xml file, which is also used by the counter part of the application in windows. The problem that I have is that I've been looking around but I haven't found a way to modify an element or attribute in an xml, without having to build the whole xml again. I saw this other post, which is basically the same problem that I have, and I also end it up in the same point as the person asking the question, NSXMLParser and TouchXML are read only and do not allowed me to modify my xml. Any other suggestion about what can I use? Thanks!

    Read the article

  • Are protocols inheritable in Objective-C?

    - by aquaibm
    I saw this in some header file in the framework directory: @interface NSCharacterSet : NSObject <NSCopying, NSMutableCopying, NSCoding> @end @interface NSMutableCharacterSet : NSCharacterSet <NSCopying, NSMutableCopying> @end I thought protocols were inheritable.If I am right about that,There is no need to type <NSCopying, NSMutableCopying> again after "NSMutableCharacterSet : NSCharacterSet".And NSMutableCharacterSet also conforms to NSCoding protocol, right? Than why is Apple typing that again?Am I making mistake?

    Read the article

  • C Objects in Objective-C

    - by paul simmons
    Hi, I couldn't find a clear explanation, just asking to be sure; are C data types handled same way (in terms of memory management) in Obj.C? i.e. they are created on stack, released immediately etc.? So they differ from Obj.C objects? Or may we make an analogy with C# (just an analogy not exactly) so that C types are handled as 'value types' and Obj.C objects as 'reference types'?

    Read the article

  • how to tell which object called a delegate method (objective c)

    - by user353877
    Let's say you have two objects (UITextviews) in your class. When the text view changes, you have a delegate method that catches the change.. but how can you tell programatically WHICH object was changed and called the delegate ?? I have to be missing something, because this should be trivial, but I couldnt find anything. Note: In this case, its not possible to just break up the class to only have one object (there by bypassing ambiguity).. I looked for things like assigned variable names for nsobjects, nothing there

    Read the article

  • Objective-C Passing a variable to another IBAction

    - by StuR
    This works fine: NSString *myVariable; - (IBAction) doFirstAction { myVariable = @"123456789"; } - (IBAction) doSecondAction { NSLog(@"%@",myVariable); } However, if I do this (substituting the @"123456789" for some code which returns the same value ie "123456789") I cannot access the value in doSecondAction. NSString *myVariable; - (IBAction) doFirstAction { myVariable = [imageNode getAttributeName:@"value"]; } - (IBAction) doSecondAction { NSLog(@"%@",myVariable); } Any clue as to why I cant access myVariable outside of doFirstAction?

    Read the article

  • callbacks via objective-c selectors

    - by codemonkey
    I have a "BSjax" class that I wrote that lets me make async calls to our server to get json result sets, etc using the ASIHTTPRequest class. I set it up so that the BSjax class parses my server's json response, then passes control back to the calling view controller via this call: [[self delegate] performSelectorOnMainThread:@selector(bsRequestFinished:) withObject:self waitUntilDone:YES]; ... where "bsRequestFinished" is the callback method in the calling view controller. This all worked fine and well until I realized that some pages are going to need to make different types of requests... i.e. I'll want to do different types of things in that callback function depending on which type of request was made. To me it seems like being able to pass different callback function names to my BSjax class would be the cleanest fix... but I'm having trouble (and am not even sure if it's possible) to pass in a variable that holds the callback function name and then replace the call above with something like this: [[self delegate] performSelectorOnMainThread:@selector(self.variableCallbackFunctionName) withObject:self waitUntilDone:YES]; ... where "self.variableCallbackFunctionName" is set by the calling view controller when it calls BSjax to make a new request. Is this even possible? If so, advisable? If not, alternatives? EDIT: Note that whatever fix I arrive at will need to take into account the reality that this class is making async requests... so I need to make sure that the callback function processing is correctly tied to the specific requests... as I can't rely on FIFO processing sequence.

    Read the article

  • Objective C LValue required as unary '&' operand

    - by Bob
    Hello! In my code, I get this error when I try to get a pointer to my class property. (I wrote a small *.OBJ file translator in Python, discarding the normals) CODE: //line: line of text const char *str = [line UTF8String]; Point3D *p1, *p2, *p3; p1 = [Point3D makeX:0 Y:0 Z:0]; p2 = [Point3D makeX:0 Y:0 Z:0]; p3 = [Point3D makeX:0 Y:0 Z:0]; sscanf(str, "t %f,%f,%f %f,%f,%f %f,%f,%f",(&[p1 x]),&([p1 y]),&([p1 z]),&([p2 x]),&([p2 y]),&([p2 z]),&([p3 x]),&([p3 y]),&([p3 z])); Triangle3D *tri = [Triangle3D make:p1 p2:p2 p3:p3];

    Read the article

  • Copying blocks (ie: copying them to instance variables) in Objective-C

    - by RyanWilcox
    I'm trying to understand blocks. I get how to use them normally, when passed directly to a method. I'm interested now in taking a block, storing it (say) in an instance variable and calling it later. The blocks programming guide makes it sound like I can do this, by using Block_copy / retain to copy the block away, but when I try to run it I crash my program. - (void) setupStoredBlock { int salt = 42; m_storedBlock = ^(int incoming){ return 2 + incoming + salt; }; [m_storedBlock retain]; } I try to call it later: - (void) runStoredBlock { int outputValue = m_storedBlock(5); NSLog(@"When we ran our stored blockwe got back: %d", outputValue); [m_storedBlock release]; } Anyone have any insights? (Or, is there something I'm not getting with blocks?) Thank you very much!

    Read the article

  • Objective-C - Unloading loaded view when it is swapped

    - by teepusink
    Hi, What is the best way to do view management in a multiview application? Right now I have this ViewSwitcher method/function that comes from a custom delegate I created. The code is a whole bunch of if else like this MyViewController *c = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil]; c.delegate = self; self.myViewController = c; [self.viewHolder insertSubview:c.view atIndex:0]; [c release]; That works fine, but when I visited the function a second time, is there going to be 2 instances of MyViewController now or just 1? How do I unload MyViewController when I switch to another view? Or is there a better way to manage my views? Thanks, Tee

    Read the article

  • Objective C number keypad, custom comma button

    - by rom_j
    I'm trying to add a comma button on a number keypad that has previous, next and done buttons, so that it looks like this : Problem is, that the orange button does not respond to taps. Actually if I moved it above the "7" button and tapped it, the 7 would be tapped. So my orange button may be shown above the keyboard, but it's reacting to taps as if it were below. Here is an abstract of my code : -(void)textFieldDidBeginEditing:(UITextField *)textField{ UIView *inputAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 500, screenWidth, 40.0)]; // 3 buttons on top UIView *topToolbar = [[UIView alloc] initWithFrame:CGRectMake(0, 0.0, screenWidth, 40.0)]; [topToolbar addSubview:self.inputPrevButton]; [topToolbar addSubview:self.inputNextButton]; [topToolbar addSubview:self.inputDoneButton]; [inputAccessoryView addSubview:topToolbar]; // Comma button UIButton *commaButton = [UIButton buttonWithType:UIButtonTypeCustom]; [commaButton setFrame: CGRectMake(0, 204, 105, 52)]; [commaButton setTitle:@"." forState:UIControlStateNormal]; [commaButton addTarget:self action:@selector(addComma) forControlEvents:UIControlEventTouchUpInside]; [commaButton setBackgroundColor:[UIColor orangeColor]]; [inputAccessoryView addSubview:commaButton]; // Useless, but tried anyway [inputAccessoryView bringSubviewToFront:commaButton]; [textField setInputAccessoryView:self.inputAccessoryView]; } All I know is that I should not be doing this (which is actually not working), so what should I do ?

    Read the article

  • Can't get Jacobi algorithm to work in Objective-C

    - by Chris Long
    Hi, For some reason, I can't get this program to work. I've had other CS majors look at it and they can't figure it out either. This program performs the Jacobi algorithm (you can see step-by-step instructions and a MATLAB implementation here). BTW, it's different from the Wikipedia article of the same name. Since NSArray is one-dimensional, I added a method that makes it act like a two-dimensional C array. After running the Jacobi algorithm many times, the diagonal entries in the NSArray (i[0][0], i[1][1], etc.) are supposed to get bigger and the others approach 0. For some reason though, they all increase exponentially. For instance, i[2][4] should equal 0.0000009, not 9999999, while i[2][2] should be big. Thanks in advance, Chris NSArray+Matrix.m @implementation NSArray (Matrix) @dynamic offValue, transposed; - (double)offValue { double sum = 0.0; for ( MatrixItem *item in self ) if ( item.nonDiagonal ) sum += pow( item.value, 2.0 ); return sum; } - (NSMutableArray *)transposed { NSMutableArray *transpose = [[[NSMutableArray alloc] init] autorelease]; int i, j; for ( i = 0; i < 5; i++ ) { for ( j = 0; j < 5; j++ ) { [transpose addObject:[self objectAtRow:j andColumn:i]]; } } return transpose; } - (id)objectAtRow:(NSUInteger)row andColumn:(NSUInteger)column { NSUInteger index = 5 * row + column; return [self objectAtIndex:index]; } - (NSMutableArray *)multiplyWithMatrix:(NSArray *)array { NSMutableArray *result = [[NSMutableArray alloc] init]; int i = 0, j = 0, k = 0; double value; for ( i = 0; i < 5; i++ ) { value = 0.0; for ( j = 0; j < 5; j++ ) { for ( k = 0; k < 5; k++ ) { MatrixItem *firstItem = [self objectAtRow:i andColumn:k]; MatrixItem *secondItem = [array objectAtRow:k andColumn:j]; value += firstItem.value * secondItem.value; } MatrixItem *item = [[MatrixItem alloc] initWithValue:value]; item.row = i; item.column = j; [result addObject:item]; } } return result; } @end Jacobi_AlgorithmAppDelegate.m // ... - (void)jacobiAlgorithmWithEntry:(MatrixItem *)entry { MatrixItem *b11 = [matrix objectAtRow:entry.row andColumn:entry.row]; MatrixItem *b22 = [matrix objectAtRow:entry.column andColumn:entry.column]; double muPlus = ( b22.value + b11.value ) / 2.0; muPlus += sqrt( pow((b22.value - b11.value), 2.0) + 4.0 * pow(entry.value, 2.0) ); Vector *u1 = [[[Vector alloc] initWithX:(-1.0 * entry.value) andY:(b11.value - muPlus)] autorelease]; [u1 normalize]; Vector *u2 = [[[Vector alloc] initWithX:-u1.y andY:u1.x] autorelease]; NSMutableArray *g = [[[NSMutableArray alloc] init] autorelease]; for ( int i = 0; i <= 24; i++ ) { MatrixItem *item = [[[MatrixItem alloc] init] autorelease]; if ( i == 6*entry.row ) item.value = u1.x; else if ( i == 6*entry.column ) item.value = u2.y; else if ( i == ( 5*entry.row + entry.column ) || i == ( 5*entry.column + entry.row ) ) item.value = u1.y; else if ( i % 6 == 0 ) item.value = 1.0; else item.value = 0.0; [g addObject:item]; } NSMutableArray *firstResult = [[g.transposed multiplyWithMatrix:matrix] autorelease]; matrix = [firstResult multiplyWithMatrix:g]; } // ...

    Read the article

  • Passing array to another class - Objective C

    - by Darko Hebrang
    I manage to pass the following array from MessagesTableViewController.m to arraySelectedCategory in another class called MessageDetailViewController.m: self.messageDetailViewController.arraySelectedCategory = [[NSMutableArray alloc] initWithObjects:@"Value 1",@"Value 2", @"Value 3", nil]; but how do I hand over an array stored in: NSMutableArray *categories; self.messageDetailViewController.arraySelectedCategory = ????? Thanks!

    Read the article

  • What is the '^' in Objective-C

    - by Chris Paterson
    What does the '^' mean in the code below? @implementation AppController - (IBAction) loadComposition:(id)sender { void (^handler)(NSInteger); NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setAllowedFileTypes:[NSArray arrayWithObjects: @"qtz", nil]]; handler = ^(NSInteger result) { if (result == NSFileHandlingPanelOKButton) { NSString *filePath = [[[panel URLs] objectAtIndex:0] path]; if (![qcView loadCompositionFromFile:filePath]) { NSLog(@"Could not load composition"); } } }; [panel beginSheetModalForWindow:qcWindow completionHandler:handler]; } @end === I've searched and searched - is it some sort of particular reference to memory?

    Read the article

  • Changing RGB color image to Grayscale image using Objective C

    - by user567167
    I was developing a application that changes color image to gray image. However, some how the picture comes out wrong. I dont know what is wrong with the code. maybe the parameter that i put in is wrong please help. UIImage *c = [UIImage imageNamed:@"downRed.png"]; CGImageRef cRef = CGImageRetain(c.CGImage); NSData* pixelData = (NSData*) CGDataProviderCopyData(CGImageGetDataProvider(cRef)); size_t w = CGImageGetWidth(cRef); size_t h = CGImageGetHeight(cRef); unsigned char* pixelBytes = (unsigned char *)[pixelData bytes]; unsigned char* greyPixelData = (unsigned char*) malloc(w*h); for (int y = 0; y < h; y++) { for(int x = 0; x < w; x++){ int iter = 4*(w*y+x); int red = pixe lBytes[iter]; int green = pixelBytes[iter+1]; int blue = pixelBytes[iter+2]; greyPixelData[w*y+x] = (unsigned char)(red*0.3 + green*0.59+ blue*0.11); int value = greyPixelData[w*y+x]; } } CFDataRef imgData = CFDataCreate(NULL, greyPixelData, w*h); CGDataProviderRef imgDataProvider = CGDataProviderCreateWithCFData(imgData); size_t width = CGImageGetWidth(cRef); size_t height = CGImageGetHeight(cRef); size_t bitsPerComponent = 8; size_t bitsPerPixel = 8; size_t bytesPerRow = CGImageGetWidth(cRef); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); CGBitmapInfo info = kCGImageAlphaNone; CGFloat *decode = NULL; BOOL shouldInteroplate = NO; CGColorRenderingIntent intent = kCGRenderingIntentDefault; CGDataProviderRelease(imgDataProvider); CGImageRef throughCGImage = CGImageCreate(width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpace, info, imgDataProvider, decode, shouldInteroplate, intent); UIImage* newImage = [UIImage imageWithCGImage:throughCGImage]; CGImageRelease(throughCGImage); newImageView.image = newImage;

    Read the article

  • Objective-c pointer assignment and reassignment dilema

    - by moshe
    Hi, If I do this: 1 NSMutableArray *near = [[NSMutableArray alloc] init]; 2 NSMutableArray *all = [[NSMutableArray alloc] init]; 3 NSMutableArray *current = near; 4 current = all; What happens to near? At line 3, am I setting current to point to the same address as near so that I now have two variables pointing to the same place in memory, or am I setting current to point to the location of near in memory such that I now have this structure: current - near - NSMutableArray The obvious difference would be the value of near at line 4. If the former is happening, near is untouched and still points to its initial place in memory. If the latter is happening,

    Read the article

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