Search Results

Search found 8409 results on 337 pages for 'itunes sdk'.

Page 56/337 | < Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >

  • How to check for local Wi-Fi (not just cellular connection) using iPhone SDK?

    - by Michael
    I'm currently using the following to check whether Wi-Fi is available for my application: #import <SystemConfiguration/SystemConfiguration.h> static inline BOOL addressReachable(const struct sockaddr_in *hostAddress); BOOL localWiFiAvailable() { struct sockaddr_in localWifiAddress; bzero(&localWifiAddress, sizeof(localWifiAddress)); localWifiAddress.sin_len = sizeof(localWifiAddress); localWifiAddress.sin_family = AF_INET; // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0 localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM); return addressReachable(&localWifiAddress); } static inline BOOL addressReachable(const struct sockaddr_in *hostAddress) { const SCNetworkReachabilityRef target = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)hostAddress); if (target != NULL) { SCNetworkReachabilityFlags flags = 0; const BOOL reachable = SCNetworkReachabilityGetFlags(target, &flags); CFRelease(target); return reachable && (flags & kSCNetworkFlagsReachable); } return NO; } This, however, does not return NO as it should when the iPhone is connected only to a cellular network but not a Wi-Fi network. Does anyone know how to fix this? Edit So this is what I ended up using: #import <arpa/inet.h> // For AF_INET, etc. #import <ifaddrs.h> // For getifaddrs() #import <net/if.h> // For IFF_LOOPBACK BOOL localWiFiAvailable() { struct ifaddrs *addresses; struct ifaddrs *cursor; BOOL wiFiAvailable = NO; if (getifaddrs(&addresses) != 0) return NO; cursor = addresses; while (cursor != NULL) { if (cursor -> ifa_addr -> sa_family == AF_INET && !(cursor -> ifa_flags & IFF_LOOPBACK)) // Ignore the loopback address { // Check for WiFi adapter if (strcmp(cursor -> ifa_name, "en0") == 0) { wiFiAvailable = YES; break; } } cursor = cursor -> ifa_next; } freeifaddrs(addresses); return wiFiAvailable; } Thanks "unforgiven" (and Matt Brown apparently).

    Read the article

  • IPhone sdk stop the accelerometer from working when something happens.

    - by Harry
    Hi, I am using the accelerometer to move a few UIImageViews around the screen, at the moment the accelerometer only works when a NSTimer is at 0, this is fine. I would also like to make the accelerometer stop again when a different function happens. here is my code at the moment: -(BOOL) accelerometerWorks { return time == 0; } -(void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{ if(![self accelerometerWorks]) return; valueX = acceleration.x*25.5; int newX = (int)(ball.center.x +valueX); if (newX 320-BALL_RADIUS) newX = 320-BALL_RADIUS; if (newX < 0+BALL_RADIUS) newX = 0+BALL_RADIUS; int XA = (int)(balloonbit1.center.x +valueX); if (XA 320-BALL_RADIUS) XA = 320-BALL_RADIUS; if (XA < 0+BALL_RADIUS) XA = 0+BALL_RADIUS; int XB = (int)(balloonbit2.center.x +valueX); if (XB 320-BALL_RADIUS) XB = 320-BALL_RADIUS; if (XB < 0+BALL_RADIUS) XB = 0+BALL_RADIUS; int XI = (int)(balloonbit3.center.x +valueX); if (XI 320-BALL_RADIUS) XI = 320-BALL_RADIUS; if (XI < 0+BALL_RADIUS) XI = 0+BALL_RADIUS; int XJ = (int)(balloonbit4.center.x +valueX); if (XJ 320-BALL_RADIUS) XJ = 320-BALL_RADIUS; if (XJ < 0+BALL_RADIUS) XJ = 0+BALL_RADIUS; int XE = (int)(balloonbit5.center.x +valueX); if (XE 320-BALL_RADIUS) XE = 320-BALL_RADIUS; if (XE < 0+BALL_RADIUS) XE = 0+BALL_RADIUS; int XF = (int)(balloonbit6.center.x +valueX); if (XF 320-BALL_RADIUS) XF = 320-BALL_RADIUS; if (XF < 0+BALL_RADIUS) XF = 0+BALL_RADIUS; int XH = (int)(balloonbit8.center.x +valueX); if (XH 320-BALL_RADIUS) XH = 320-BALL_RADIUS; if (XH < 0+BALL_RADIUS) XH = 0+BALL_RADIUS; ball.center = CGPointMake (newX, 429); balloonbit1.center = CGPointMake (XA, 429); balloonbit2.center = CGPointMake (XB, 426); balloonbit3.center = CGPointMake (XI, 410); balloonbit4.center = CGPointMake (XJ, 415); balloonbit5.center = CGPointMake (XE, 409); balloonbit6.center = CGPointMake (XF, 427); balloonbit8.center = CGPointMake (XH, 417); } This all works fine, i would now like to stop the accelerometer from working, using the same accelerometerWorks method or a new method, accelerometerWontWork. This is the code that when it is called i would like the accelerometer to stop. (it is very long so i wont put all of it there, but its all the same throughout): -(void) checkCollision{ if (CGRectIntersectsRect(pinend.frame, balloonbit1.frame)){ if (balloonbit1.frame.origin.y pinend.frame.origin.y){ [maintimer invalidate]; levelfailed.center = CGPointMake (160, 235); } } if (CGRectIntersectsRect(pinend.frame, balloonbit2.frame)){ if (balloonbit2.frame.origin.y pinend.frame.origin.y){ [maintimer invalidate]; levelfailed.center = CGPointMake (160, 235); } } if (CGRectIntersectsRect(pinend.frame, balloonbit3.frame)){ if (balloonbit3.frame.origin.y pinend.frame.origin.y){ [maintimer invalidate]; levelfailed.center = CGPointMake (160, 235); } } } I understand that i may have to turn this into a BOOL. Thats fine. If i haven't explained it well please say and i will re write it. Thanks! Harry.

    Read the article

  • iPhone SDK: Know when tab on Tab Bar is clicked?

    - by Nic Hubbard
    I have a tab bar which displays different views when clicked. When you click a tab for the first time, it calls the viewDidLoad method. But, it only calls that the first time. Is there a method that is called when a user clicks back to that tab, since the viewDidLoad won't be called that second time? (I need to do this to update a UITableView when the user clicks back to a tab)

    Read the article

  • Facebook SDK , How To Put Name of user in wall post?

    - by Viola Courtney
    I got this code and working fine $access_token = $facebook->getAccessToken(); $vars = array( 'caption' => 'Caption message', 'message' => 'I need help', 'name' => 'I need Help', 'link' => 'http://www.google.com/', 'description' => 'description', 'picture' => '' ); But I want to replace the message or the name in to like : " (name of user) Need Help...

    Read the article

  • iPhone SDK: Can a UIButton with custom images display the title?

    - by Harkonian
    If I create a custom UIButton with images for UIControlState normal and UIControlStateSelected, am I still supposed to be able to display the title for the button? Currently I can't. This is how I create my button: UIImage *moveButtonImage = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"button_move_inactive" ofType:@"png"] ]; UIImage *moveButtonSelectedImage = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"button_move_pressed" ofType:@"png"] ]; self.moveButton = [UIButton buttonWithType:UIButtonTypeCustom]; [self.moveButton setImage : moveButtonImage forState : UIControlStateNormal]; [self.moveButton setImage : moveButtonSelectedImage forState : UIControlStateSelected]; [self.moveButton setTitle:@"Test" forState:UIControlStateNormal]; The button title never displays in this case and I'm forced to create my own label to display on the button, which seems like a hacky way of doing things. Maybe I'm doing something wrong here?

    Read the article

  • iphone sdk: autorotate jumps back up the page, showing information that has already been read...

    - by jonathan
    Hi, I am using - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ return YES; } to allow rotation, which works fine - except that the landscape view jumps backwards up the page that is being displayed. I can't figure out what I should be looking at to fix it. I just want the page to rotate where it is. Any pointers would be great. Am a noob, as is probably clear. Thanks Jonathan

    Read the article

  • Converting image to Black & White image on iPhone SDK issues.

    - by KfirS
    Hello, I've used a familiar code to convert image to Black & White which I've founded on several forums. The code is: CGColorSpaceRef colorSapce = CGColorSpaceCreateDeviceGray(); CGContextRef context = CGBitmapContextCreate(nil, originalImage.size.width, originalImage.size.height, 8, originalImage.size.width, colorSapce, kCGImageAlphaNone); CGContextSetInterpolationQuality(context, kCGInterpolationHigh); CGContextSetShouldAntialias(context, NO); CGContextDrawImage(context, CGRectMake(0, 0, originalImage.size.width, originalImage.size.height), [originalImage CGImage]); CGImageRef bwImage = CGBitmapContextCreateImage(context); CGContextRelease(context); CGColorSpaceRelease(colorSapce); UIImage *resultImage = [UIImage imageWithCGImage:bwImage]; // This is result B/W image. CGImageRelease(bwImage); return resultImage; When I'm using this code with on Horizontal image it's work fine, but when I'm trying a to use this code on Vertical image, the result is disproportionate image and rotate 90 degree left. Can anyone know what could be the problem? Thanks, Kfir.

    Read the article

  • Inserting a string array as a row into an Excel document using the Open XML SDK 2.0

    - by Sam
    The code runs, but corrupts my excel document. Any help would be mucho appreciated! I used this as a reference. public void AddRow(string fileName, string[] values) { using (SpreadsheetDocument doc = SpreadsheetDocument.Open(fileName, true)) { SharedStringTablePart sharedStringPart = GetSharedStringPart(doc); WorksheetPart worksheetPart = doc.WorkbookPart.WorksheetParts.First(); uint rowIdx = AppendRow(worksheetPart); for (int i = 0; i < values.Length; ++i) { int stringIdx = InsertSharedString(values[i], sharedStringPart); Cell cell = InsertCell(i, rowIdx, worksheetPart); cell.CellValue = new CellValue(stringIdx.ToString()); cell.DataType = new EnumValue<CellValues>( CellValues.SharedString); worksheetPart.Worksheet.Save(); } } } private SharedStringTablePart GetSharedStringPart( SpreadsheetDocument doc) { if (doc.WorkbookPart. GetPartsCountOfType<SharedStringTablePart>() > 0) return doc.WorkbookPart. GetPartsOfType<SharedStringTablePart>().First(); else return doc.WorkbookPart. AddNewPart<SharedStringTablePart>(); } private uint AppendRow(WorksheetPart worksheetPart) { SheetData sheetData = worksheetPart.Worksheet. GetFirstChild<SheetData>(); uint rowIndex = (uint)sheetData.Elements<Row>().Count(); Row row = new Row() { RowIndex = rowIndex }; sheetData.Append(row); return rowIndex; } private int InsertSharedString(string s, SharedStringTablePart sharedStringPart) { if (sharedStringPart.SharedStringTable == null) sharedStringPart.SharedStringTable = new SharedStringTable(); int i = 0; foreach (SharedStringItem item in sharedStringPart.SharedStringTable. Elements<SharedStringItem>()) { if (item.InnerText == s) return i; ++i; } sharedStringPart.SharedStringTable.AppendChild( new Text(s)); sharedStringPart.SharedStringTable.Save(); return i; } private Cell InsertCell(int i, uint rowIdx, WorksheetPart worksheetPart) { SheetData sheetData = worksheetPart.Worksheet. GetFirstChild<SheetData>(); string cellReference = AlphabetMap.Instance[i] + rowIdx; Cell cell = new Cell() { CellReference = cellReference }; Row row = sheetData.Elements<Row>().ElementAt((int)rowIdx); row.InsertAt(cell, i); worksheetPart.Worksheet.Save(); return cell; }

    Read the article

  • iPhone SDK: How to store the time each word was typed?

    - by Harkonian
    My problem is twofold: 1) I'm trying to determine an eloquent way to allow the user to type into a UITextView and store the time each word was typed into an array. The time will be a float which starts at 0 when the user begins to type. 2) Conversely, I'd like the user to be able to tap on a word in the UITextView and display the time that word was typed (displaying in an NSLog() is fine). Considerations that may throw a wrench into a possible approach -- what if the user goes back to the top of the text and starts typing or to the middle of the text? Even a suggested approach without code would be appreciated, because right now I'm drawing a blank.

    Read the article

  • How to make RegexKitLite w/ iPhone SDK produce a list of all matches +/- and also return surrounding

    - by Matt
    I'd like to create a regular expression that will match and return based on the following criteria: 1) I have N search terms entered by a user 2) I have a body of text. 3) I want to return a list of all the occurrences of all the search terms entered by the user plus surrounding context. I think (\w+\W+){,4}(", ")(\W+\w+){,4} might work. 4) I don't know how to use RegexKitLite at all. Do I invoke a RegexKitLite class? or does it interface into NSString somehow?

    Read the article

  • Does iPhone SDK Objective C support functions inside of functions?

    - by Moshe
    I know that javascript, for example supports functions inside of functions, like so: function doSomething(){ function doAnothingThing(){ //this function is redefined every time doSomething() is called and only exists inside doSomething() } //you can also stick it inside of conditions if(yes){ function doSomethingElse(){ //this function only exists if yes is true } } } Does objective-c support this? Theoretical example: -(void) doSomething:(id) sender{ -(void) respondToEvent: (id) sender{ //theoretically? ... please? } } BONUS: What is the proper term for a "local" function?

    Read the article

  • iPhone SDK: Downloading large files from a server into the app bundle.

    - by Jessica
    Hi, I am building an app that plays multiple video files, But I would like to know How do you download a video file (100mb - 300mb) from a server into the application's bundle so it can later be locally referred to in code? The reason I want this type of a set up in my app is that I don't want the app binary to be made unnecessarily large due to including videos some users may not want. Also does this violate any of apple's terms? Also would it be simple to implement a progress view with this kind of set up and if so how? Any help is appreciated.

    Read the article

  • how to know whether dealloc is getting called or not in iphone sdk?

    - by chaitanya
    hi.. i am using UIviewcontroller subclasses. In my main view i have 3 buttons, each button will load a different nib. and each new nib is having one back button to come back to main view. when i click one the back button of any view to move to the main view the dealloc of that view is not getting called? i didnt understood this. can anyone explain when those views dealloc will be called?

    Read the article

  • iPhone SDK: problem managing orientation with multiple view controllers.

    - by Tom
    I'm trying to build an iPhone application that has two subviews in the main window. Each view has its own UIViewController subclass associated with it. Also, within each controller's implementation, I've added the following method: -(BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation { return YES; } Thus, I would expect both of the views to respond to changes in orientation. However, this is not the case. Only the first view added to the app's main window responds to orientation. (If I swap the order the views are added, then only the other view responds. In other words, either will work--but only one at a time.) Why is this? Is it not possible to handle the orientation changes of more than one view? Thanks! EDIT: Someone else had this question, so I'm copying my solution here: I was able to address this issue by providing a root view and a root view controller with the method "shouldAutoRotate..." and adding my other views as subviews to the root view. The subviews inherit the auto-rotating behavior, and their associated view controllers shouldn't need to override "shouldAutoRotate..."

    Read the article

  • iPhone SDK: How do I programatically change the background image of a UIButton added to a NIB?

    - by user304583
    I've seen several questions/answers related to entirely creating a button in code, but not one which would let me know how to change the button image in code, when I originally added the button to my NIB in Interface Builder. I know how to change the background in Interface Builder.. but I want to change it in code, so I can change it automagically. Any help really appreciated! Perhaps the answer is so obvious nobody needs to ask.. if so please forgive the dweeb that I am and help! :-)

    Read the article

  • iPhone SDK: Check validity of URLs with NSURL not working??

    - by Chris
    hi, I'm trying to check if a given URL is valid and i'm doing it like this: - (BOOL)urlIsValid:(NSString *)address { NSURL *testURL = [NSURL URLWithString:address]; if (testURL == nil) { return NO; } else { return YES; } } Since "URLWithString" is supposed to return "nil" if the URL is malformed I thought this would work but it doesn't for some reason. Could someone please tell me why? Thanks in advance!

    Read the article

  • iPhone SDK: How to center map around a particular point?

    - by buzzappsoftware
    New to MapKit. Having problems centering map around a specified point. Here is the code. Not sure why this is not working. We are expecting to see a map centered around Cincinnati, OH. What we are seeing is the default google map of the world. Any help appreciated. / Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; CLLocationCoordinate2D mapCoords[2]; mapCoords[0].latitude = 39.144057; mapCoords[0].latitude = -84.505484; mapCoords[1].latitude = 39.142984; mapCoords[1].latitude = -84.502534; MKCoordinateSpan span; span.latitudeDelta = 0.2; span.longitudeDelta = 0.2; MKCoordinateRegion region; region.center = mapCoords[0]; region.span = span; [mapView setRegion:region animated:YES]; }

    Read the article

  • How do I change the build's SDK version in Xcode?

    - by Kavon Farvardin
    I'm using Xcode 2.5 on Mac 10.4.11 PPC. javac -version returns 1.5.x yet when I imported my source code and tried to build it in Xcode, I get errors all over because generics, annotations, and for-each loops are not supported in -source 1.3. I thought I found the setting to change the source version in Xcode in the above but it doesn't work. Any ideas?

    Read the article

< Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >