Questions tagged [foundation]

Foundation is a framework written in Objective-C that implements many useful classes and functions. For the responsive front-end framework Zurb Foundation, please use the tag [zurb-foundation].

Foundation is a framework written in Objective-C that implements many useful classes and functions. Foundation is used by almost any Objective-C application, as it provides memory management and other runtime features, without the need to use the Objective-C runtime API directly.


References

Related Topics

Separate Topics

This topic is often confused with:

878 questions
459
votes
16 answers

How to check if an NSDictionary or NSMutableDictionary contains a key?

I need to check if an dict has a key or not. How?
dontWatchMyProfile
  • 42,456
  • 49
  • 169
  • 255
146
votes
7 answers

How to Get the Title of a HTML Page Displayed in UIWebView?

I need to extract the contents of the title tag from an HTML page displayed in a UIWebView. What is the most robust means of doing so? I know I can do: - (void)webViewDidFinishLoad:(UIWebView *)webView{ NSString *theTitle=[webView…
TechZen
  • 63,819
  • 15
  • 116
  • 144
89
votes
3 answers

Adding an object at a specific index of an NSMutableArray

How can an object be added at a specific index of an NSMutableArray? How is an object added to the front of the array?
some_id
  • 28,294
  • 58
  • 173
  • 293
79
votes
7 answers

Catching NSException in Swift

The following code in Swift raises NSInvalidArgumentException exception: task = NSTask() task.launchPath = "/SomeWrongPath" task.launch() How can I catch the exception? As I understand, try/catch in Swift is for errors thrown within Swift, not for…
silyevsk
  • 3,351
  • 3
  • 26
  • 27
71
votes
16 answers

Comparing NSDates without time component

In a swift playground, I have been using NSDate.date() But, this always appears with the time element appended. For my app I need to ignore the time element. Is this possible in Swift? How can it be done? Even if I could set the time element to be…
agf119105
  • 1,572
  • 4
  • 12
  • 22
70
votes
3 answers

Difference between Foundation Framework and Core Foundation Framework?

I try to get the hang of it, but for now both seem the same thing to me. However, Xcode allows to create an Console App with choice of using "Core Foundation" or just "Foundation". Maybe someone can point out the differences.
openfrog
  • 37,829
  • 61
  • 213
  • 364
62
votes
9 answers

Replace substring of NSAttributedString with another NSAttributedString

I want to replace a substring (e.g. @"replace") of an NSAttributedString with another NSAttributedString. I am looking for an equivalent method to NSString's stringByReplacingOccurrencesOfString:withString: for NSAttributedString.
Garoal
  • 2,304
  • 2
  • 17
  • 31
58
votes
8 answers

Is there a constant for the maximum CGFloat value?

I need to create a CGSize to compute text height of an arbitrary text with arbitrary length. UIKit has this nice method -sizeWithFont:constrainedToSize: and my text is only constrained in width, but not in height. For this, I need to set the maximum…
Proud Member
  • 38,700
  • 43
  • 143
  • 225
53
votes
11 answers

How to calculate the age based on NSDate

how to calculate the age based on the birth date in this format 6/24/1976 mon/date/year...
Linux world
  • 3,674
  • 11
  • 41
  • 59
51
votes
9 answers

Print the size (megabytes) of Data in Swift

I have a variable fileData of Data type and I am struggling to find how to print the size of this. In the past NSData you would print the length but unable to do that with this type. How to print the size of a Data in Swift?
user2512523
  • 989
  • 2
  • 11
  • 23
39
votes
3 answers

import Swift vs import Foundation

Question What is the difference between import Swift and import Foundation? Until I read this comment by Martin R, I didn't even know that there was an import Swift. Reading I couldn't find the documentation and doing a Google search didn't turn up…
Suragch
  • 364,799
  • 232
  • 1,155
  • 1,198
38
votes
1 answer

Swift class vs Cocoa Touch Class in Xcode6

I am new to iOS development and have started directly with Swift. When I want to add a new file to a project, the IDE presents me with two files which seem to be used interchangeably in the tutorials that I have seen so far. They are "Cocoa Touch…
Rajeev Bhatia
  • 2,894
  • 1
  • 17
  • 29
33
votes
3 answers

What am I doing wrong with allowsFractionalUnits on NSDateComponentsFormatter?

Basically what I want is to get the value of a time interval represented in hours only, without rounding it to full hours (using NSDateComponentsFormatter to get it properly formatted and localized). I don't know if I misunderstand the use of…
osanoj
  • 1,015
  • 10
  • 8
32
votes
4 answers

How to use NSIndexSet

In Objective-C, my program opens a window and displays a table. I want to have a specified row of the table highlighted. How do I do this? I seem to need the code [myTableView selectRowIndexes:(NSIndexSet *) byExtendingSelection:(BOOL)]; I looked…
hertopnerd
  • 588
  • 1
  • 4
  • 9
32
votes
1 answer

Can't pass Date to NSPredicate(format: ...) without "as CVarArg"

Is this how I'm supposed to pass a Date to NSPredicate.init(format predicateFormat: String, arguments argList: CVaListPointer). let endDate = Date() NSPredicate(format: "endDate == %@", endDate as CVarArg) It looks kinda clumsy, and I suspect I'm…
netigger
  • 3,390
  • 3
  • 23
  • 42
1
2 3
58 59