
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
github.com/alexruperez/ARAutocompleteTextView
ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time. This is perfect for automatically suggesting the domain as a user types an email address, #hashtag or @handle.
ARAutocompleteTextView.m
ARAutocompleteTextView.h
ARAutocompleteManager.m
ARAutocompleteManager.h
Create an ARAutocompleteTextView
instance exactly as as you would UITextView
. You can do eith either programmitcally or in Interface Builder. Programmatically, this looks like:
ARAutocompleteTextView* textField = [[ARAutocompleteTextView alloc] initWithFrame:CGRectMake(0,0,100,31)];
let textField = ARAutocompleteTextView(frame: CGRectMake(0, 0, 100, 31))
The data source is the brains of the autocomplete logic. If you just want to autocomplete email addresses, #hashtags or @handles, use ARAutocompleteManager
from the example project as follows:
textField.autocompleteDataSource = [ARAutocompleteManager sharedManager];
textField.autocompleteType = ARAutocompleteTypeEmail;
textField.autocompleteDataSource = ARAutocompleteManager.sharedManager()
textField.autocompleteType = ARAutocompleteType.Mail
ARAutocompleteManager
(included in the example project) provides email address autocompletion out of the box. It comes with a list of the top email domains. You may want to tailor this list of email domains to match your own customers, or you may want to write autocomplete logic for a different type of text view (in the demo, names of colors are autocompleted).
Alternatively, you may wish to create your own data source class and user the autocompleteType
property to differentiate between textviews with different data types. A ARAutocompleteTextView
's data source must implement the following method, as part of the ARAutocompleteDataSource
protocol.
- (NSString *)textField:(ARAutocompleteTextView*)textField completionForPrefix:(NSString *)prefix
You may also set a default dataSource
for all instances of ARAutocompleteTextView
. In the example project, we use a ARAutocompleteManager
singleton:
[autocompleteTextOffset setDefaultAutocompleteDataSource:[ARAutocompleteManager sharedManager]];
To adjust the position of the autocomplete label by a fixed amount, set autocompleteTextOffset
:
textField.autocompleteTextOffset = CGPointMake(10.0, 10.0);
For more dynamic positioning of the autocomplete label, subclass ARAutocompleteTextView
and override - (CGRect)autocompleteRectForBounds:(CGRect)bounds
.
To adjust the properties (i.e. font
, textColor
) of the autocomplete label, do so via the `[AutocompleteTextField autocompleteLabel] property.
textField.autocompleteLabel.textColor = [UIColor grayColor];
In addition to observing the standard UITextView
notifications (i.e. UITextViewTextDidChangeNotification
and friends), you can use [ARAutocompleteTextView autoCompleteTextFieldDelegate]
to listen for certain events. This is particularly useful if you are collecting analytics.
Tweet the author @alexruperez, and check out alexruperez's blog: http://alexruperez.com
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.